Gantt Chart python machine scheduling
<p>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. </p>

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

<p>Let me show what data set I have with a small example:</p>

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

<p>I tried to use the <a href="http://matplotlib.org/examples/pylab_examples/broken_barh.html" rel="nofollow">broken_barh</a> 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.</p>

<p><a href="http://i.stack.imgur.com/ea3eL.gif" rel="nofollow">Here is a picture</a> to show how the output should look like.</p>

<p>Current code bellow:</p>

<pre><code>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()
</code></pre>

<p>Seimetz,</p>

<p>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:
<a href="http://demos.radiantq.com/jQueryGanttDemo/Samples/ServerStatusWithHugeData.htm" rel="nofollow">http://demos.radiantq.com/jQueryGanttDemo/Samples/ServerStatusWithHugeData.htm</a></p>

<p>This is how it looks:
<a href="http://i.stack.imgur.com/VyzsO.png" rel="nofollow">Server Status Sample</a></p>

<p>More on the product here:
<a href="http://radiantq.com/products/jquery-gantt-package/jquery-gantt-package-features/" rel="nofollow">http://radiantq.com/products/jquery-gantt-package/jquery-gantt-package-features/</a></p>

python matplotlib job-scheduling gantt-chart