Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0542e13

Browse files
committed
update version check for basic charts in python/version2
1 parent 24f61f9 commit 0542e13

26 files changed

+515
-1220
lines changed

_posts/python-version2/basic/area/2015-06-30-area.html

Lines changed: 105 additions & 123 deletions
Large diffs are not rendered by default.

_posts/python-version2/basic/area/area.ipynb

Lines changed: 108 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,14 @@
99
"<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",
1010
"<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!\n",
1111
"#### Version Check\n",
12-
"Plotly's python package is updated frequently. Run `pip install plotly --upgrade` to use the latest version. "
13-
]
14-
},
15-
{
16-
"cell_type": "code",
17-
"execution_count": 1,
18-
"metadata": {},
19-
"outputs": [
20-
{
21-
"data": {
22-
"text/plain": [
23-
"'3.1.1'"
24-
]
25-
},
26-
"execution_count": 1,
27-
"metadata": {},
28-
"output_type": "execute_result"
29-
}
30-
],
31-
"source": [
32-
"import plotly\n",
33-
"plotly.__version__"
12+
"This is documentation for version 2 of plotly.py. See the [changelog](https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md#270---2018-05-23) for differences between package versions."
3413
]
3514
},
3615
{
3716
"cell_type": "markdown",
38-
"metadata": {},
17+
"metadata": {
18+
"collapsed": true
19+
},
3920
"source": [
4021
"#### Basic Overlaid Area Chart"
4122
]
@@ -48,7 +29,7 @@
4829
{
4930
"data": {
5031
"text/html": [
51-
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/429.embed\" height=\"525px\" width=\"100%\"></iframe>"
32+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2887.embed\" height=\"525px\" width=\"100%\"></iframe>"
5233
],
5334
"text/plain": [
5435
"<plotly.tools.PlotlyDisplay object>"
@@ -75,12 +56,14 @@
7556
")\n",
7657
"\n",
7758
"data = [trace1, trace2]\n",
78-
"py.iplot(data, filename='basic-area')"
59+
"py.iplot(data, filename='basic-area-v2')"
7960
]
8061
},
8162
{
8263
"cell_type": "markdown",
83-
"metadata": {},
64+
"metadata": {
65+
"collapsed": true
66+
},
8467
"source": [
8568
"#### Overlaid Area Chart Without Boundary Lines"
8669
]
@@ -93,7 +76,7 @@
9376
{
9477
"data": {
9578
"text/html": [
96-
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/431.embed\" height=\"525px\" width=\"100%\"></iframe>"
79+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2889.embed\" height=\"525px\" width=\"100%\"></iframe>"
9780
],
9881
"text/plain": [
9982
"<plotly.tools.PlotlyDisplay object>"
@@ -122,12 +105,14 @@
122105
")\n",
123106
"\n",
124107
"data = [trace1, trace2]\n",
125-
"py.iplot(data, filename='basic-area-no-bound')"
108+
"py.iplot(data, filename='basic-area-no-bound-v2')"
126109
]
127110
},
128111
{
129112
"cell_type": "markdown",
130-
"metadata": {},
113+
"metadata": {
114+
"collapsed": true
115+
},
131116
"source": [
132117
"#### Interior Filling for Area Chart"
133118
]
@@ -140,7 +125,7 @@
140125
{
141126
"data": {
142127
"text/html": [
143-
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/433.embed\" height=\"525px\" width=\"100%\"></iframe>"
128+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2891.embed\" height=\"525px\" width=\"100%\"></iframe>"
144129
],
145130
"text/plain": [
146131
"<plotly.tools.PlotlyDisplay object>"
@@ -175,14 +160,16 @@
175160
")\n",
176161
"\n",
177162
"data = [trace0, trace1]\n",
178-
"py.iplot(data, filename='filling-interior-area')"
163+
"py.iplot(data, filename='filling-interior-area-v2')"
179164
]
180165
},
181166
{
182167
"cell_type": "markdown",
183-
"metadata": {},
168+
"metadata": {
169+
"collapsed": true
170+
},
184171
"source": [
185-
"#### Stacked Area Chart"
172+
"### Stacked Area Chart with Cumulative Values"
186173
]
187174
},
188175
{
@@ -193,7 +180,7 @@
193180
{
194181
"data": {
195182
"text/html": [
196-
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/437.embed\" height=\"525px\" width=\"100%\"></iframe>"
183+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2893.embed\" height=\"525px\" width=\"100%\"></iframe>"
197184
],
198185
"text/plain": [
199186
"<plotly.tools.PlotlyDisplay object>"
@@ -208,47 +195,60 @@
208195
"import plotly.plotly as py\n",
209196
"import plotly.graph_objs as go\n",
210197
"\n",
211-
"# Add original data\n",
212-
"x=['Winter', 'Spring', 'Summer', 'Fall']\n",
213-
"\n",
214-
"trace0 = dict(\n",
215-
" x=x,\n",
216-
" y=[40, 60, 40, 10],\n",
217-
" hoverinfo='x+y',\n",
198+
"trace0 = go.Scatter(\n",
199+
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
200+
" y=['40', '20', '30', '40'],\n",
218201
" mode='lines',\n",
219202
" line=dict(width=0.5,\n",
220-
" color='rgb(131, 90, 241)'),\n",
221-
" stackgroup='one'\n",
203+
" color='rgb(184, 247, 212)'),\n",
204+
" fill='tonexty'\n",
222205
")\n",
223-
"trace1 = dict(\n",
224-
" x=x,\n",
225-
" y=[20, 10, 10, 60],\n",
226-
" hoverinfo='x+y',\n",
206+
"trace1 = go.Scatter(\n",
207+
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
208+
" y=['50', '70', '40', '60'],\n",
227209
" mode='lines',\n",
228210
" line=dict(width=0.5,\n",
229211
" color='rgb(111, 231, 219)'),\n",
230-
" stackgroup='one'\n",
212+
" fill='tonexty'\n",
231213
")\n",
232-
"trace2 = dict(\n",
233-
" x=x,\n",
234-
" y=[40, 30, 50, 30],\n",
235-
" hoverinfo='x+y',\n",
214+
"trace2 = go.Scatter(\n",
215+
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
216+
" y=['70', '80', '60', '70'],\n",
236217
" mode='lines',\n",
237218
" line=dict(width=0.5,\n",
238-
" color='rgb(184, 247, 212)'),\n",
239-
" stackgroup='one'\n",
219+
" color='rgb(127, 166, 238)'),\n",
220+
" fill='tonexty'\n",
240221
")\n",
241-
"data = [trace0, trace1, trace2]\n",
242-
"\n",
243-
"fig = dict(data=data)\n",
244-
"py.iplot(fig, filename='stacked-area-plot-hover', validate=False)"
222+
"trace3 = go.Scatter(\n",
223+
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
224+
" y=['100', '100', '100', '100'],\n",
225+
" mode='lines',\n",
226+
" line=dict(width=0.5,\n",
227+
" color='rgb(131, 90, 241)'),\n",
228+
" fill='tonexty'\n",
229+
")\n",
230+
"data = [trace0, trace1, trace2, trace3]\n",
231+
"layout = go.Layout(\n",
232+
" showlegend=True,\n",
233+
" xaxis=dict(\n",
234+
" type='category',\n",
235+
" ),\n",
236+
" yaxis=dict(\n",
237+
" type='linear',\n",
238+
" range=[1, 100],\n",
239+
" dtick=20,\n",
240+
" ticksuffix='%'\n",
241+
" )\n",
242+
")\n",
243+
"fig = go.Figure(data=data, layout=layout)\n",
244+
"py.iplot(fig, filename='stacked-area-plot-v2')"
245245
]
246246
},
247247
{
248248
"cell_type": "markdown",
249249
"metadata": {},
250250
"source": [
251-
"### Stacked Area Chart with Normalized Values"
251+
"#### Stacked Area Chart with Original Values"
252252
]
253253
},
254254
{
@@ -259,7 +259,7 @@
259259
{
260260
"data": {
261261
"text/html": [
262-
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2805.embed\" height=\"525px\" width=\"100%\"></iframe>"
262+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2895.embed\" height=\"525px\" width=\"100%\"></iframe>"
263263
],
264264
"text/plain": [
265265
"<plotly.tools.PlotlyDisplay object>"
@@ -274,54 +274,57 @@
274274
"import plotly.plotly as py\n",
275275
"import plotly.graph_objs as go\n",
276276
"\n",
277-
"trace0 = dict(\n",
278-
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
279-
" y=['40', '20', '30', '40'],\n",
277+
"# Add original data\n",
278+
"x=['Winter', 'Spring', 'Summer', 'Fall']\n",
279+
"\n",
280+
"y0_org=[40, 60, 40, 10]\n",
281+
"y1_org=[20, 10, 10, 60]\n",
282+
"y2_org=[40, 30, 50, 30]\n",
283+
"\n",
284+
"# Add data to create cumulative stacked values\n",
285+
"y0_stck=y0_org\n",
286+
"y1_stck=[y0+y1 for y0, y1 in zip(y0_org, y1_org)]\n",
287+
"y2_stck=[y0+y1+y2 for y0, y1, y2 in zip(y0_org, y1_org, y2_org)]\n",
288+
"\n",
289+
"# Make original values strings and add % for hover text\n",
290+
"y0_txt=[str(y0)+'%' for y0 in y0_org]\n",
291+
"y1_txt=[str(y1)+'%' for y1 in y1_org]\n",
292+
"y2_txt=[str(y2)+'%' for y2 in y2_org]\n",
293+
"\n",
294+
"trace0 = go.Scatter(\n",
295+
" x=x,\n",
296+
" y=y0_stck,\n",
297+
" text=y0_txt,\n",
298+
" hoverinfo='x+text',\n",
280299
" mode='lines',\n",
281300
" line=dict(width=0.5,\n",
282-
" color='rgb(184, 247, 212)'),\n",
283-
" stackgroup='one',\n",
284-
" groupnorm='percent'\n",
301+
" color='rgb(131, 90, 241)'),\n",
302+
" fill='tonexty'\n",
285303
")\n",
286-
"trace1 = dict(\n",
287-
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
288-
" y=['50', '70', '40', '60'],\n",
304+
"trace1 = go.Scatter(\n",
305+
" x=x,\n",
306+
" y=y1_stck,\n",
307+
" text=y1_txt,\n",
308+
" hoverinfo='x+text',\n",
289309
" mode='lines',\n",
290310
" line=dict(width=0.5,\n",
291311
" color='rgb(111, 231, 219)'),\n",
292-
" stackgroup='one'\n",
293-
")\n",
294-
"trace2 = dict(\n",
295-
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
296-
" y=['70', '80', '60', '70'],\n",
297-
" mode='lines',\n",
298-
" line=dict(width=0.5,\n",
299-
" color='rgb(127, 166, 238)'),\n",
300-
" stackgroup='one'\n",
312+
" fill='tonexty'\n",
301313
")\n",
302-
"trace3 = dict(\n",
303-
" x=['Winter', 'Spring', 'Summer', 'Fall'],\n",
304-
" y=['100', '100', '100', '100'],\n",
314+
"trace2 = go.Scatter(\n",
315+
" x=x,\n",
316+
" y=y2_stck,\n",
317+
" text=y2_txt,\n",
318+
" hoverinfo='x+text',\n",
305319
" mode='lines',\n",
306320
" line=dict(width=0.5,\n",
307-
" color='rgb(131, 90, 241)'),\n",
308-
" stackgroup='one'\n",
309-
")\n",
310-
"data = [trace0, trace1, trace2, trace3]\n",
311-
"layout = go.Layout(\n",
312-
" showlegend=True,\n",
313-
" xaxis=dict(\n",
314-
" type='category',\n",
315-
" ),\n",
316-
" yaxis=dict(\n",
317-
" type='linear',\n",
318-
" range=[1, 100],\n",
319-
" dtick=20,\n",
320-
" ticksuffix='%'\n",
321-
" )\n",
321+
" color='rgb(184, 247, 212)'),\n",
322+
" fill='tonexty'\n",
322323
")\n",
323-
"fig = dict(data=data, layout=layout)\n",
324-
"py.iplot(fig, filename='stacked-area-plot-norm', validate=False)"
324+
"data = [trace0, trace1, trace2]\n",
325+
"\n",
326+
"fig = go.Figure(data=data)\n",
327+
"py.iplot(fig, filename='stacked-area-plot-hover-v2')"
325328
]
326329
},
327330
{
@@ -339,7 +342,7 @@
339342
{
340343
"data": {
341344
"text/html": [
342-
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2502.embed\" height=\"525px\" width=\"100%\"></iframe>"
345+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2897.embed\" height=\"525px\" width=\"100%\"></iframe>"
343346
],
344347
"text/plain": [
345348
"<plotly.tools.PlotlyDisplay object>"
@@ -393,7 +396,7 @@
393396
")\n",
394397
"\n",
395398
"fig = go.Figure(data=data,layout=layout)\n",
396-
"py.iplot(data, filename='select-hover-points')"
399+
"py.iplot(data, filename='select-hover-points-v2')"
397400
]
398401
},
399402
{
@@ -408,7 +411,7 @@
408411
},
409412
{
410413
"cell_type": "code",
411-
"execution_count": 8,
414+
"execution_count": 1,
412415
"metadata": {},
413416
"outputs": [
414417
{
@@ -440,17 +443,17 @@
440443
"output_type": "stream",
441444
"text": [
442445
"Collecting git+https://github.com/plotly/publisher.git\n",
443-
" Cloning https://github.com/plotly/publisher.git to /tmp/pip-req-build-ewWF0_\n",
446+
" Cloning https://github.com/plotly/publisher.git to /tmp/pip-req-build-QQFrBt\n",
444447
"Building wheels for collected packages: publisher\n",
445448
" Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n",
446-
"\u001b[?25h Stored in directory: /tmp/pip-ephem-wheel-cache-zaYWOc/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n",
449+
"\u001b[?25h Stored in directory: /tmp/pip-ephem-wheel-cache-Se8qIh/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n",
447450
"Successfully built publisher\n",
448451
"Installing collected packages: publisher\n",
449452
" Found existing installation: publisher 0.11\n",
450453
" Uninstalling publisher-0.11:\n",
451454
" Successfully uninstalled publisher-0.11\n",
452455
"Successfully installed publisher-0.11\n",
453-
"\u001b[33mYou are using pip version 10.0.1, however version 18.0 is available.\n",
456+
"\u001b[33mYou are using pip version 10.0.1, however version 18.1 is available.\n",
454457
"You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
455458
]
456459
}
@@ -504,5 +507,5 @@
504507
}
505508
},
506509
"nbformat": 4,
507-
"nbformat_minor": 2
510+
"nbformat_minor": 1
508511
}

0 commit comments

Comments
 (0)