Gantt Chart

Some preliminaries

If you are wondering why in the world this webpage looks the way it does, it might help you to review Anaconda, Jupyter scripts and a basic Python example. You can do so by reviewing the post(s) below.

You can download this script at the bottom of this post.

Using Plotly

In this post we implement something called a "Gantt" chart. You can learn more about Gantt charts here:

Turns out charts of this kind are good for creating project schedules. Not the most obvious application of python visualization, but could be useful in some situations. I note thate there could be better alternatives for creating a timeline, such as this one I found (https://www.preceden.com/).

The chart below is developed using Plotly (https://plot.ly). This is a "freemium" service (i.e. free for some functionality, with premium option that must be purchased). My understanding is that in the basic version the charts you create are public (but the data remains private). You will need to create a free account on their website in order to get a username and API Key and begin using plotly.

You will have to initialize plotly the first time you use it, you can learn more about how to do it here: https://plot.ly/python/getting-started/#initialization-for-online-plotting

In [15]:
#initializing plotly (see above)
#import plotly 
#plotly.tools.set_credentials_file(username='Your Account', api_key='*******')
In [14]:
import plotly.plotly as py
import plotly.figure_factory as ff

df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28', Complete=15),
      dict(Task="Job B", Start='2008-12-05', Finish='2009-04-15', Complete=60),
      dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30', Complete=90)]

fig = ff.create_gantt(df,colors='RdBu', index_col='Complete',show_colorbar=True)
fig['layout']['xaxis']['rangeselector']['visible'] = False
fig['layout']['xaxis']['rangeslider'] = dict(bgcolor='#E2E2E2')
fig['layout']['xaxis']['type'] = 'date'
py.iplot(fig, filename='gantt-simple-gantt-chart')
Out[14]:

Click and move the sliders in the graph above in order to zoom in or out of a particular section of the timeline!

In [ ]: