Gantt Chart python machine scheduling
Question: I'm having some bad time trying to plot a gantt chart from a data set with
python. I have a set of machines that work on different tasks during a time
period. I want to make a gantt chart that shows by the y axis the machines and
x axis the time spent on each task. Each machine should appear just once on
the y axis and to make easier to see the tasks I want the same color for each
task.

The idea is to check strange things like having the same task being processed
by two or more machines together.

Let me show what data set I have with a small example:

    
    
    machine   equipment   start   finish
      m1         e2       date1    date2
      m2         e2       date3    date4
      m1         e1       date5    date6
      m3         e3       date7    date8
      m3         e4       date9    date10
    

I tried to use the
[broken_barh](http://matplotlib.org/examples/pylab_examples/broken_barh.html)
from matplotlib, but I can't figure out a way to add the data for the plot
efficiently. Since I have some thing like 100 machines and 400 tasks.

[Here is a picture](http://i.stack.imgur.com/ea3eL.gif) to show how the output
should look like.

Current code bellow:

    
    
    import datetime as dt
    
    machines = set(list(mydata["machine"]))
    tasks = set(list(mydata["task"]))
    
    fig, ax = plt.subplots(figsize=(20, 10))
    
    yrange = 5 # y width of gantt bar
    ymin = 0
    orign = min(list(mydata["start"])) # time origin
    
    for i in machines:
    
        stdur = [] # list of tuples (start, duration)
        ymin = index*6 # start y of gantt bar
    
        for index, row in mydata.iterrows():
    
            if row["machine"] == i:
                start = (row["start"] -  orign).total_seconds()/3600
                duration = (row["finish"] -  row["start"]).total_seconds()/3600
    
                stdur.append((start,duration))
    
        ax.broken_barh(stdur,(ymin,yrange))
    
    ax.set_xlabel('Time')
    ax.set_yticklabels(machines)
    
    plt.show()
    


Answer: Seimetz,

If you are fine passing the entire data to the client and let a JS Gantt do
it's thing, then the RadiantQ jQuery Gantt Package will be a better option for
you. Here is an online demo of something similar:
<http://demos.radiantq.com/jQueryGanttDemo/Samples/ServerStatusWithHugeData.htm>

This is how it looks: [Server Status
Sample](http://i.stack.imgur.com/VyzsO.png)

More on the product here: <http://radiantq.com/products/jquery-gantt-
package/jquery-gantt-package-features/>

