-
-
Notifications
You must be signed in to change notification settings - Fork 543
HTML to ipynb for bubble, bar, area, box, error bar and quiver-plots #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
af8454f
4160d0f
e7d739d
a08d04c
4a536a8
cca2025
9d83fdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,291 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"#### New to Plotly?\n", | ||
"Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).\n", | ||
"<br>You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/#start-plotting-online).\n", | ||
"<br>We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Version Check\n", | ||
"Plotly's python package is updated frequently. Run `pip install plotly --upgrade` to use the latest version." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'3.1.1'" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import plotly\n", | ||
"plotly.__version__" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Making a Stacked-Line Plot with Matplotlib" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~priyatharsan/683.embed\" height=\"288px\" width=\"432px\&qu 8000 ot;></iframe>" | ||
], | ||
"text/plain": [ | ||
"<plotly.tools.PlotlyDisplay object>" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import plotly.plotly as py\n", | ||
"import plotly.tools as tls\n", | ||
"\n", | ||
"# Learn about API authentication here: https://plot.ly/python/getting-started\n", | ||
"# Find your api_key here: https://plot.ly/settings/api\n", | ||
"\n", | ||
"# create our stacked data manually\n", | ||
"y0 = np.random.rand(100)\n", | ||
"y1 = y0 + np.random.rand(100)\n", | ||
"y2 = y1 + np.random.rand(100)\n", | ||
"capacity = 3*np.ones(100)\n", | ||
"\n", | ||
"# make the mpl plot (no fill yet)\n", | ||
"fig, ax = plt.subplots()\n", | ||
"ax.plot(y0, label='y0')\n", | ||
"ax.plot(y1, label='y1')\n", | ||
"ax.plot(y2, label='y2')\n", | ||
"ax.plot(capacity, label='capacity')\n", | ||
"\n", | ||
"# set all traces' \"fill\" so that it fills to the next 'y' trace\n", | ||
"update = {'data':[{'fill': 'tonexty'}]}\n", | ||
"\n", | ||
"# strip style just lets Plotly make the styling choices (e.g., colors)\n", | ||
"plotly_fig = tls.mpl_to_plotly( fig )\n", | ||
"plotly_fig.update(update)\n", | ||
"py.iplot(plotly_fig, strip_style=True, filename='mpl-stacked-line')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Multiple-Line Area Plot" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~priyatharsan/685.embed\" height=\"288px\" width=\"432px\"></iframe>" | ||
], | ||
"text/plain": [ | ||
"<plotly.tools.PlotlyDisplay object>" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import plotly.plotly as py\n", | ||
"import plotly.tools as tls\n", | ||
"\n", | ||
"# Learn about API authentication here: https://plot.ly/python/getting-started\n", | ||
"# Find your api_key here: https://plot.ly/settings/api\n", | ||
"\n", | ||
"x = np.linspace(0, 2*np.pi, 100)\n", | ||
"fig, ax = plt.subplots()\n", | ||
"ax.plot(np.sin(x), label='sin'); ax.plot(np.cos(x), label='cos')\n", | ||
"\n", | ||
"update = {'data':[{'fill': 'tozeroy'}]} # this updates BOTH traces now\n", | ||
"plotly_fig = tls.mpl_to_plotly( fig )\n", | ||
"plotly_fig.update(update)\n", | ||
"py.iplot(plotly_fig, filename='mpl-multi-fill')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Matplotlib Area Plot" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typically we want the examples to be in order from most basic -> most advanced on the page. This seems like the most basic example so I suggest moving this first. |
||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~priyatharsan/687.embed\" height=\"288px\" width=\"432px\"></iframe>" | ||
], | ||
"text/plain": [ | ||
"<plotly.tools.PlotlyDisplay object>" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"import plotly.plotly as py\n", | ||
"import plotly.tools as tls\n", | ||
"\n", | ||
"# Learn about API authentication here: https://plot.ly/python/getting-started\n", | ||
"# Find your api_key here: https://plot.ly/settings/api\n", | ||
"\n", | ||
"fig, ax = plt.subplots()\n", | ||
"ax.plot([2,1,3,1,2])\n", | ||
"\n", | ||
"update = {'data':[{'fill': 'tozeroy'}]} # this updates the trace\n", | ||
"plotly_fig = tls.mpl_to_plotly( fig )\n", | ||
"plotly_fig.update(update)\n", | ||
"py.iplot(plotly_fig, update=update, filename='mpl-basic-area')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Reference\n", | ||
"See https://plot.ly/python/filled-area-plots/ for more information and chart attribute options!" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<link href=\"//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700\" rel=\"stylesheet\" type=\"text/css\" />" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.HTML object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.HTML object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Collecting git+https://github.com/plotly/publisher.git\n", | ||
" Cloning https://github.com/plotly/publisher.git to c:\\users\\thars\\appdata\\local\\temp\\pip-req-build-vlcbys\n", | ||
"Building wheels for collected packages: publisher\n", | ||
" Running setup.py bdist_wheel for publisher: started\n", | ||
" Running setup.py bdist_wheel for publisher: finished with status 'done'\n", | ||
" Stored in directory: c:\\users\\thars\\appdata\\local\\temp\\pip-ephem-wheel-cache-_vaayl\\wheels\\99\\3e\\a0\\fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", | ||
"Successfully built publisher\n", | ||
"Installing collected packages: publisher\n", | ||
" Found existing installation: publisher 0.11\n", | ||
" Uninstalling publisher-0.11:\n", | ||
" Successfully uninstalled publisher-0.11\n", | ||
"Successfully installed publisher-0.11\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from IPython.display import display, HTML\n", | ||
"\n", | ||
"display(HTML('<link href=\"//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700\" rel=\"stylesheet\" type=\"text/css\" />'))\n", | ||
"display(HTML('<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">'))\n", | ||
"\n", | ||
"! pip install git+https://github.com/plotly/publisher.git --upgrade\n", | ||
"import publisher\n", | ||
"publisher.publish(\n", | ||
" 'matplotlib_area.ipynb', 'matplotlib/filled-area-plots/', 'Filled Area Plots',\n", | ||
" 'How to make a filled area plot in matplotlib. An area chart displays a solid color between the traces of a graph.',\n", | ||
" title = 'Matplotlib Filled Area Plots | Plotly',\n", | ||
" has_thumbnail='true', thumbnail='thumbnail/area.jpg',\n", | ||
" language='matplotlib',\n", | ||
" page_type='example_index',\n", | ||
" display_as='basic', ipynb='~notebook_demo/246')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 2", | ||
"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.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it again, I don't think that we require these commented lines anymore. They seem redundant given that this information is contained in the New to Plotly? section.