8000 HTML to ipynb for bubble, bar, area, box, error bar and quiver-plots by priyatharsan · Pull Request #1048 · plotly/documentation · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 7 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions _posts/matplotlib/area/2015-04-09-area_matplotlib_index.html

This file was deleted.

19 changes: 0 additions & 19 deletions _posts/matplotlib/area/2015-04-09-mpl-basic-area.html

This file was deleted.

21 changes: 0 additions & 21 deletions _posts/matplotlib/area/2015-04-09-mpl-multi-fill.html

This file was deleted.

33 changes: 0 additions & 33 deletions _posts/matplotlib/area/2015-04-09-mpl-stacked-line.html

This file was deleted.

256 changes: 256 additions & 0 deletions _posts/matplotlib/area/2015-06-30-matplotlib_area.html

Large diffs are not rendered by default.

305 changes: 305 additions & 0 deletions _posts/matplotlib/area/matplotlib_area.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
{
"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": [
"#### Area Plot"
]
},
{
"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/687.embed\" height=\"288px\" width=\"432px\"></iframe>"
],
"text/plain": [
"<plotly.tools.PlotlyDisplay object>"
]
},
"execution_count": 2,
"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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Learn about API authentication here: https://plot.ly/python/getting-started
# Find your api_key here: https://plot.ly/settings/api

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.

"\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": [
"#### 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": [
"#### Stacked Line Plot"
]
},
{
"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/683.embed\" height=\"288px\" width=\"432px\"></iframe>"
],
"text/plain": [
"<plotly.tools.PlotlyDisplay object>"
]
},
10000 "execution_count": 4,
"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": [
"#### Reference\n",
"See https://plot.ly/python/filled-area-plots/ for more information and chart attribute options!"
]
},
{
"cell_type": "code",
"execution_count": 5,
"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-j1q7bm\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-d3mdxz\\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"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Anaconda\\Anaconda2\\lib\\site-packages\\IPython\\nbconvert.py:13: ShimWarning:\n",
"\n",
"The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n",
"\n",
"C:\\Anaconda\\Anaconda2\\lib\\site-packages\\publisher\\publisher.py:53: UserWarning:\n",
"\n",
"Did you \"Save\" this notebook before running this command? Remember to save, always save.\n",
"\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-pl 95F0 ots/', '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
}
Loading
0