Created
December 7, 2017 17:25
-
-
Save empet/e402e54c2e1c0f0630cbd46e40e8de30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Forum: Gantt+scatter plot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window.Plotly) {{require(['plotly'],function(plotly) {window.Plotly=plotly;});}}</script>" | |
], | |
"text/vnd.plotly.v1+html": [ | |
"<script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window.Plotly) {{require(['plotly'],function(plotly) {window.Plotly=plotly;});}}</script>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, plot\n", | |
"init_notebook_mode(connected=True)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Plot a Gantt chart:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.plotly.v1+json": { | |
"data": [ | |
{ | |
"marker": { | |
"color": "white" | |
}, | |
"name": "", | |
"x": [ | |
"2009-01-01", | |
"2009-02-01" | |
], | |
"y": [ | |
0, | |
0 | |
] | |
}, | |
{ | |
"marker": { | |
"color": "white" | |
}, | |
"name": "", | |
"x": [ | |
"2009-03-05", | |
"2009-04-15" | |
], | |
"y": [ | |
1, | |
1 | |
] | |
}, | |
{ | |
"marker": { | |
"color": "white" | |
}, | |
"name": "", | |
"x": [ | |
"2009-04-20", | |
"2009-09-30" | |
], | |
"y": [ | |
2, | |
2 | |
] | |
}, | |
{ | |
"hoverinfo": "none", | |
"marker": { | |
"color": "rgb(210, 60, 180)", | |
"size": 1 | |
}, | |
"name": "Apple", | |
"showlegend": true, | |
"x": [ | |
"2009-04-20", | |
"2009-04-20" | |
], | |
"y": [ | |
0, | |
0 | |
] | |
}, | |
{ | |
"hoverinfo": "none", | |
"marker": { | |
"color": "rgb(51, 178, 76)", | |
"size": 1 | |
}, | |
"name": "Banana", | |
"showlegend": true, | |
"x": [ | |
"2009-04-20", | |
"2009-04-20" | |
], | |
"y": [ | |
1, | |
1 | |
] | |
}, | |
{ | |
"hoverinfo": "none", | |
"marker": { | |
"color": "rgb(122, 5, 4)", | |
"size": 1 | |
}, | |
"name": "Grape", | |
"showlegend": true, | |
"x": [ | |
"2009-04-20", | |
"2009-04-20" | |
], | |
"y": [ | |
2, | |
2 | |
] | |
} | |
], | |
"layout": { | |
"height": 600, | |
"hovermode": "closest", | |
"shapes": [ | |
{ | |
"fillcolor": "rgb(210, 60, 180)", | |
"line": { | |
"width": 0 | |
}, | |
"opacity": 1, | |
"type": "rect", | |
"x0": "2009-01-01", | |
"x1": "2009-02-01", | |
"xref": "x", | |
"y0": -0.2, | |
"y1": 0.2, | |
"yref": "y" | |
}, | |
{ | |
"fillcolor": "rgb(122, 5, 4)", | |
"line": { | |
"width": 0 | |
}, | |
"opacity": 1, | |
"type": "rect", | |
"x0": "2009-03-05", | |
"x1": "2009-04-15", | |
"xref": "x", | |
"y0": 0.8, | |
"y1": 1.2, | |
"yref": "y" | |
}, | |
{ | |
"fillcolor": "rgb(51, 178, 76)", | |
"line": { | |
"width": 0 | |
}, | |
"opacity": 1, | |
"type": "rect", | |
"x0": "2009-04-20", | |
"x1": "2009-09-30", | |
"xref": "x", | |
"y0": 1.8, | |
"y1": 2.2, | |
"yref": "y" | |
} | |
], | |
"showlegend": true, | |
"title": "Gantt Chart", | |
"width": 900, | |
"xaxis": { | |
"rangeselector": { | |
"buttons": [ | |
{ | |
"count": 7, | |
"label": "1w", | |
"step": "day", | |
"stepmode": "backward" | |
}, | |
{ | |
"count": 1, | |
"label": "1m", | |
"step": "month", | |
"stepmode": "backward" | |
}, | |
{ | |
"count": 6, | |
"label": "6m", | |
"step": "month", | |
"stepmode": "backward" | |
}, | |
{ | |
"count": 1, | |
"label": "YTD", | |
"step": "year", | |
"stepmode": "todate" | |
}, | |
{ | |
"count": 1, | |
"label": "1y", | |
"step": "year", | |
"stepmode": "backward" | |
}, | |
{ | |
"step": "all" | |
} | |
] | |
}, | |
"showgrid": false, | |
"type": "date", | |
"zeroline": false | |
}, | |
"yaxis": { | |
"autorange": false, | |
"range": [ | |
-1, | |
4 | |
], | |
"showgrid": false, | |
"ticktext": [ | |
"Job A", | |
"Job B", | |
"Job C" | |
], | |
"tickvals": [ | |
0, | |
1, | |
2 | |
], | |
"zeroline": false | |
} | |
} | |
}, | |
"text/html": [ | |
"<div id=\"62916e4c-bb1c-461a-bb0e-ef990d6cf1e7\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"62916e4c-bb1c-461a-bb0e-ef990d6cf1e7\", [{\"marker\": {\"color\": \"white\"}, \"y\": [0, 0], \"name\": \"\", \"x\": [\"2009-01-01\", \"2009-02-01\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [1, 1], \"name\": \"\", \"x\": [\"2009-03-05\", \"2009-04-15\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [2, 2], \"name\": \"\", \"x\": [\"2009-04-20\", \"2009-09-30\"]}, {\"showlegend\": true, \"name\": \"Apple\", \"y\": [0, 0], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(210, 60, 180)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Banana\", \"y\": [1, 1], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(51, 178, 76)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Grape\", \"y\": [2, 2], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(122, 5, 4)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}], {\"showlegend\": true, \"title\": \"Gantt Chart\", \"yaxis\": {\"showgrid\": false, \"range\": [-1, 4], \"zeroline\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"autorange\": false, \"tickvals\": [0, 1, 2]}, \"height\": 600, \"shapes\": [{\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(210, 60, 180)\", \"y1\": 0.2, \"y0\": -0.2, \"x0\": \"2009-01-01\", \"x1\": \"2009-02-01\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(122, 5, 4)\", \"y1\": 1.2, \"y0\": 0.8, \"x0\": \"2009-03-05\", \"x1\": \"2009-04-15\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(51, 178, 76)\", \"y1\": 2.2, \"y0\": 1.8, \"x0\": \"2009-04-20\", \"x1\": \"2009-09-30\", \"type\": \"rect\", \"line\": {\"width\": 0}}], \"width\": 900, \"xaxis\": {\"zeroline\": false, \"rangeselector\": {\"buttons\": [{\"count\": 7, \"step\": \"day\", \"stepmode\": \"backward\", \"label\": \"1w\"}, {\"count\": 1, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"1m\"}, {\"count\": 6, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"6m\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"todate\", \"label\": \"YTD\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"backward\", \"label\": \"1y\"}, {\"step\": \"all\"}]}, \"type\": \"date\", \"showgrid\": false}, \"hovermode\": \"closest\"}, {\"linkText\": \"Export to plot.ly\", \"showLink\": true})});</script>" | |
], | |
"text/vnd.plotly.v1+html": [ | |
"<div id=\"62916e4c-bb1c-461a-bb0e-ef990d6cf1e7\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"62916e4c-bb1c-461a-bb0e-ef990d6cf1e7\", [{\"marker\": {\"color\": \"white\"}, \"y\": [0, 0], \"name\": \"\", \"x\": [\"2009-01-01\", \"2009-02-01\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [1, 1], \"name\": \"\", \"x\": [\"2009-03-05\", \"2009-04-15\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [2, 2], \"name\": \"\", \"x\": [\"2009-04-20\", \"2009-09-30\"]}, {\"showlegend\": true, \"name\": \"Apple\", \"y\": [0, 0], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(210, 60, 180)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Banana\", \"y\": [1, 1], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(51, 178, 76)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Grape\", \"y\": [2, 2], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(122, 5, 4)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}], {\"showlegend\": true, \"title\": \"Gantt Chart\", \"yaxis\": {\"showgrid\": false, \"range\": [-1, 4], \"zeroline\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"autorange\": false, \"tickvals\": [0, 1, 2]}, \"height\": 600, \"shapes\": [{\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(210, 60, 180)\", \"y1\": 0.2, \"y0\": -0.2, \"x0\": \"2009-01-01\", \"x1\": \"2009-02-01\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(122, 5, 4)\", \"y1\": 1.2, \"y0\": 0.8, \"x0\": \"2009-03-05\", \"x1\": \"2009-04-15\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(51, 178, 76)\", \"y1\": 2.2, \"y0\": 1.8, \"x0\": \"2009-04-20\", \"x1\": \"2009-09-30\", \"type\": \"rect\", \"line\": {\"width\": 0}}], \"width\": 900, \"xaxis\": {\"zeroline\": false, \"rangeselector\": {\"buttons\": [{\"count\": 7, \"step\": \"day\", \"stepmode\": \"backward\", \"label\": \"1w\"}, {\"count\": 1, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"1m\"}, {\"count\": 6, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"6m\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"todate\", \"label\": \"YTD\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"backward\", \"label\": \"1y\"}, {\"step\": \"all\"}]}, \"type\": \"date\", \"showgrid\": false}, \"hovermode\": \"closest\"}, {\"linkText\": \"Export to plot.ly\", \"showLink\": true})});</script>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"import plotly.figure_factory as ff\n", | |
"from datetime import datetime\n", | |
"\n", | |
"df = [dict(Task=\"Job A\", Start='2009-01-01', Finish='2009-02-01', Resource='Apple'),\n", | |
" dict(Task=\"Job B\", Start='2009-03-05', Finish='2009-04-15', Resource='Grape'),\n", | |
" dict(Task=\"Job C\", Start='2009-04-20', Finish='2009-09-30', Resource='Banana')]\n", | |
"\n", | |
"colors = ['#7a0504', (0.2, 0.7, 0.3), 'rgb(210, 60, 180)']\n", | |
"\n", | |
"fig = ff.create_gantt(df, colors=colors, index_col='Resource', reverse_colors=True, show_colorbar=True)\n", | |
"iplot(fig)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Inspect `fig['data']` and `fig['layout']` in case you want to update some dicts:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[{'marker': {'color': 'white'},\n", | |
" 'name': '',\n", | |
" 'x': ['2009-01-01', '2009-02-01'],\n", | |
" 'y': [0, 0]},\n", | |
" {'marker': {'color': 'white'},\n", | |
" 'name': '',\n", | |
" 'x': ['2009-03-05', '2009-04-15'],\n", | |
" 'y': [1, 1]},\n", | |
" {'marker': {'color': 'white'},\n", | |
" 'name': '',\n", | |
" 'x': ['2009-04-20', '2009-09-30'],\n", | |
" 'y': [2, 2]},\n", | |
" {'hoverinfo': 'none',\n", | |
" 'marker': {'color': 'rgb(210, 60, 180)', 'size': 1},\n", | |
" 'name': 'Apple',\n", | |
" 'showlegend': True,\n", | |
" 'x': ['2009-04-20', '2009-04-20'],\n", | |
" 'y': [0, 0]},\n", | |
" {'hoverinfo': 'none',\n", | |
" 'marker': {'color': 'rgb(51, 178, 76)', 'size': 1},\n", | |
" 'name': 'Banana',\n", | |
" 'showlegend': True,\n", | |
" 'x': ['2009-04-20', '2009-04-20'],\n", | |
" 'y': [1, 1]},\n", | |
" {'hoverinfo': 'none',\n", | |
" 'marker': {'color': 'rgb(122, 5, 4)', 'size': 1},\n", | |
" 'name': 'Grape',\n", | |
" 'showlegend': True,\n", | |
" 'x': ['2009-04-20', '2009-04-20'],\n", | |
" 'y': [2, 2]}]" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fig['data']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'height': 600,\n", | |
" 'hovermode': 'closest',\n", | |
" 'shapes': [{'fillcolor': 'rgb(210, 60, 180)',\n", | |
" 'line': {'width': 0},\n", | |
" 'opacity': 1,\n", | |
" 'type': 'rect',\n", | |
" 'x0': '2009-01-01',\n", | |
" 'x1': '2009-02-01',\n", | |
" 'xref': 'x',\n", | |
" 'y0': -0.2,\n", | |
" 'y1': 0.2,\n", | |
" 'yref': 'y'},\n", | |
" {'fillcolor': 'rgb(122, 5, 4)',\n", | |
" 'line': {'width': 0},\n", | |
" 'opacity': 1,\n", | |
" 'type': 'rect',\n", | |
" 'x0': '2009-03-05',\n", | |
" 'x1': '2009-04-15',\n", | |
" 'xref': 'x',\n", | |
" 'y0': 0.8,\n", | |
" 'y1': 1.2,\n", | |
" 'yref': 'y'},\n", | |
" {'fillcolor': 'rgb(51, 178, 76)',\n", | |
" 'line': {'width': 0},\n", | |
" 'opacity': 1,\n", | |
" 'type': 'rect',\n", | |
" 'x0': '2009-04-20',\n", | |
" 'x1': '2009-09-30',\n", | |
" 'xref': 'x',\n", | |
" 'y0': 1.8,\n", | |
" 'y1': 2.2,\n", | |
" 'yref': 'y'}],\n", | |
" 'showlegend': True,\n", | |
" 'title': 'Gantt Chart',\n", | |
" 'width': 900,\n", | |
" 'xaxis': {'rangeselector': {'buttons': [{'count': 7,\n", | |
" 'label': '1w',\n", | |
" 'step': 'day',\n", | |
" 'stepmode': 'backward'},\n", | |
" {'count': 1, 'label': '1m', 'step': 'month', 'stepmode': 'backward'},\n", | |
" {'count': 6, 'label': '6m', 'step': 'month', 'stepmode': 'backward'},\n", | |
" {'count': 1, 'label': 'YTD', 'step': 'year', 'stepmode': 'todate'},\n", | |
" {'count': 1, 'label': '1y', 'step': 'year', 'stepmode': 'backward'},\n", | |
" {'step': 'all'}]},\n", | |
" 'showgrid': False,\n", | |
" 'type': 'date',\n", | |
" 'zeroline': False},\n", | |
" 'yaxis': {'autorange': False,\n", | |
" 'range': [-1, 4],\n", | |
" 'showgrid': False,\n", | |
" 'ticktext': ['Job A', 'Job B', 'Job C'],\n", | |
" 'tickvals': [0, 1, 2],\n", | |
" 'zeroline': False}}" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fig['layout']" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"fig['data'] is a list of dicts, while fig['layout'] is just one dict.\n", | |
"Hence you should append a new dict to fig['data'] in order to insert another trace (scatter plot, for example)." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"yaxis range is [-1, 4]. In a new scatter trace you can plot points and lines connecting them, having datetime as x-coordinates and y-coords between [-1,4].\n", | |
"If you want to extend yaxis range in the Gantt chart, perform an update like this one: \n", | |
"\n", | |
"`fig['layout']['yaxis'].update(range=[-1,6])`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"scatter_trace=dict(type='scatter',\n", | |
" x=[datetime(2009, 6, 13), datetime(2009, 7, 13)],\n", | |
" y=[1, 3])\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.plotly.v1+json": { | |
"data": [ | |
{ | |
"marker": { | |
"color": "white" | |
}, | |
"name": "", | |
"x": [ | |
"2009-01-01", | |
"2009-02-01" | |
], | |
"y": [ | |
0, | |
0 | |
] | |
}, | |
{ | |
"marker": { | |
"color": "white" | |
}, | |
"name": "", | |
"x": [ | |
"2009-03-05", | |
"2009-04-15" | |
], | |
"y": [ | |
1, | |
1 | |
] | |
}, | |
{ | |
"marker": { | |
"color": "white" | |
}, | |
"name": "", | |
"x": [ | |
"2009-04-20", | |
"2009-09-30" | |
], | |
"y": [ | |
2, | |
2 | |
] | |
}, | |
{ | |
"hoverinfo": "none", | |
"marker": { | |
"color": "rgb(210, 60, 180)", | |
"size": 1 | |
}, | |
"name": "Apple", | |
"showlegend": true, | |
"x": [ | |
"2009-04-20", | |
"2009-04-20" | |
], | |
"y": [ | |
0, | |
0 | |
] | |
}, | |
{ | |
"hoverinfo": "none", | |
"marker": { | |
"color": "rgb(51, 178, 76)", | |
"size": 1 | |
}, | |
"name": "Banana", | |
"showlegend": true, | |
"x": [ | |
"2009-04-20", | |
"2009-04-20" | |
], | |
"y": [ | |
1, | |
1 | |
] | |
}, | |
{ | |
"hoverinfo": "none", | |
"marker": { | |
"color": "rgb(122, 5, 4)", | |
"size": 1 | |
}, | |
"name": "Grape", | |
"showlegend": true, | |
"x": [ | |
"2009-04-20", | |
"2009-04-20" | |
], | |
"y": [ | |
2, | |
2 | |
] | |
}, | |
{ | |
"type": "scatter", | |
"x": [ | |
"2009-06-13", | |
"2009-07-13" | |
], | |
"y": [ | |
1, | |
3 | |
] | |
} | |
], | |
"layout": { | |
"height": 600, | |
"hovermode": "closest", | |
"shapes": [ | |
{ | |
"fillcolor": "rgb(210, 60, 180)", | |
"line": { | |
"width": 0 | |
}, | |
"opacity": 1, | |
"type": "rect", | |
"x0": "2009-01-01", | |
"x1": "2009-02-01", | |
"xref": "x", | |
"y0": -0.2, | |
"y1": 0.2, | |
"yref": "y" | |
}, | |
{ | |
"fillcolor": "rgb(122, 5, 4)", | |
"line": { | |
"width": 0 | |
}, | |
"opacity": 1, | |
"type": "rect", | |
"x0": "2009-03-05", | |
"x1": "2009-04-15", | |
"xref": "x", | |
"y0": 0.8, | |
"y1": 1.2, | |
"yref": "y" | |
}, | |
{ | |
"fillcolor": "rgb(51, 178, 76)", | |
"line": { | |
"width": 0 | |
}, | |
"opacity": 1, | |
"type": "rect", | |
"x0": "2009-04-20", | |
"x1": "2009-09-30", | |
"xref": "x", | |
"y0": 1.8, | |
"y1": 2.2, | |
"yref": "y" | |
} | |
], | |
"showlegend": true, | |
"title": "Gantt Chart", | |
"width": 900, | |
"xaxis": { | |
"rangeselector": { | |
"buttons": [ | |
{ | |
"count": 7, | |
"label": "1w", | |
"step": "day", | |
"stepmode": "backward" | |
}, | |
{ | |
"count": 1, | |
"label": "1m", | |
"step": "month", | |
"stepmode": "backward" | |
}, | |
{ | |
"count": 6, | |
"label": "6m", | |
"step": "month", | |
"stepmode": "backward" | |
}, | |
{ | |
"count": 1, | |
"label": "YTD", | |
"step": "year", | |
"stepmode": "todate" | |
}, | |
{ | |
"count": 1, | |
"label": "1y", | |
"step": "year", | |
"stepmode": "backward" | |
}, | |
{ | |
"step": "all" | |
} | |
] | |
}, | |
"showgrid": false, | |
"type": "date", | |
"zeroline": false | |
}, | |
"yaxis": { | |
"autorange": false, | |
"range": [ | |
-1, | |
4 | |
], | |
"showgrid": false, | |
"ticktext": [ | |
"Job A", | |
"Job B", | |
"Job C" | |
], | |
"tickvals": [ | |
0, | |
1, | |
2 | |
], | |
"zeroline": false | |
} | |
} | |
}, | |
"text/html": [ | |
"<div id=\"8077c8fc-0ebd-47bc-93bf-50548bbe0d41\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"8077c8fc-0ebd-47bc-93bf-50548bbe0d41\", [{\"marker\": {\"color\": \"white\"}, \"y\": [0, 0], \"name\": \"\", \"x\": [\"2009-01-01\", \"2009-02-01\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [1, 1], \"name\": \"\", \"x\": [\"2009-03-05\", \"2009-04-15\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [2, 2], \"name\": \"\", \"x\": [\"2009-04-20\", \"2009-09-30\"]}, {\"showlegend\": true, \"name\": \"Apple\", \"y\": [0, 0], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(210, 60, 180)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Banana\", \"y\": [1, 1], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(51, 178, 76)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Grape\", \"y\": [2, 2], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(122, 5, 4)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"y\": [1, 3], \"x\": [\"2009-06-13\", \"2009-07-13\"], \"type\": \"scatter\"}], {\"showlegend\": true, \"title\": \"Gantt Chart\", \"yaxis\": {\"showgrid\": false, \"range\": [-1, 4], \"zeroline\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"autorange\": false, \"tickvals\": [0, 1, 2]}, \"height\": 600, \"shapes\": [{\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(210, 60, 180)\", \"y1\": 0.2, \"y0\": -0.2, \"x0\": \"2009-01-01\", \"x1\": \"2009-02-01\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(122, 5, 4)\", \"y1\": 1.2, \"y0\": 0.8, \"x0\": \"2009-03-05\", \"x1\": \"2009-04-15\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(51, 178, 76)\", \"y1\": 2.2, \"y0\": 1.8, \"x0\": \"2009-04-20\", \"x1\": \"2009-09-30\", \"type\": \"rect\", \"line\": {\"width\": 0}}], \"width\": 900, \"xaxis\": {\"zeroline\": false, \"rangeselector\": {\"buttons\": [{\"count\": 7, \"step\": \"day\", \"stepmode\": \"backward\", \"label\": \"1w\"}, {\"count\": 1, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"1m\"}, {\"count\": 6, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"6m\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"todate\", \"label\": \"YTD\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"backward\", \"label\": \"1y\"}, {\"step\": \"all\"}]}, \"type\": \"date\", \"showgrid\": false}, \"hovermode\": \"closest\"}, {\"linkText\": \"Export to plot.ly\", \"showLink\": true})});</script>" | |
], | |
"text/vnd.plotly.v1+html": [ | |
"<div id=\"8077c8fc-0ebd-47bc-93bf-50548bbe0d41\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"8077c8fc-0ebd-47bc-93bf-50548bbe0d41\", [{\"marker\": {\"color\": \"white\"}, \"y\": [0, 0], \"name\": \"\", \"x\": [\"2009-01-01\", \"2009-02-01\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [1, 1], \"name\": \"\", \"x\": [\"2009-03-05\", \"2009-04-15\"]}, {\"marker\": {\"color\": \"white\"}, \"y\": [2, 2], \"name\": \"\", \"x\": [\"2009-04-20\", \"2009-09-30\"]}, {\"showlegend\": true, \"name\": \"Apple\", \"y\": [0, 0], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(210, 60, 180)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Banana\", \"y\": [1, 1], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(51, 178, 76)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"showlegend\": true, \"name\": \"Grape\", \"y\": [2, 2], \"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(122, 5, 4)\", \"size\": 1}, \"x\": [\"2009-04-20\", \"2009-04-20\"]}, {\"y\": [1, 3], \"x\": [\"2009-06-13\", \"2009-07-13\"], \"type\": \"scatter\"}], {\"showlegend\": true, \"title\": \"Gantt Chart\", \"yaxis\": {\"showgrid\": false, \"range\": [-1, 4], \"zeroline\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"autorange\": false, \"tickvals\": [0, 1, 2]}, \"height\": 600, \"shapes\": [{\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(210, 60, 180)\", \"y1\": 0.2, \"y0\": -0.2, \"x0\": \"2009-01-01\", \"x1\": \"2009-02-01\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(122, 5, 4)\", \"y1\": 1.2, \"y0\": 0.8, \"x0\": \"2009-03-05\", \"x1\": \"2009-04-15\", \"type\": \"rect\", \"line\": {\"width\": 0}}, {\"opacity\": 1, \"xref\": \"x\", \"yref\": \"y\", \"fillcolor\": \"rgb(51, 178, 76)\", \"y1\": 2.2, \"y0\": 1.8, \"x0\": \"2009-04-20\", \"x1\": \"2009-09-30\", \"type\": \"rect\", \"line\": {\"width\": 0}}], \"width\": 900, \"xaxis\": {\"zeroline\": false, \"rangeselector\": {\"buttons\": [{\"count\": 7, \"step\": \"day\", \"stepmode\": \"backward\", \"label\": \"1w\"}, {\"count\": 1, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"1m\"}, {\"count\": 6, \"step\": \"month\", \"stepmode\": \"backward\", \"label\": \"6m\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"todate\", \"label\": \"YTD\"}, {\"count\": 1, \"step\": \"year\", \"stepmode\": \"backward\", \"label\": \"1y\"}, {\"step\": \"all\"}]}, \"type\": \"date\", \"showgrid\": false}, \"hovermode\": \"closest\"}, {\"linkText\": \"Export to plot.ly\", \"showLink\": true})});</script>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"fig['data'].append(scatter_trace)\n", | |
"iplot(fig)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python [default]", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.13" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment