|
10 | 10 | "<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!"
|
11 | 11 | ]
|
12 | 12 | },
|
| 13 | + { |
| 14 | + "cell_type": "markdown", |
| 15 | + "metadata": {}, |
| 16 | + "source": [ |
| 17 | + "#### Version Check\n", |
| 18 | + "Plotly's python package is updated frequently. Run `pip install plotly --upgrade` to use the latest version." |
| 19 | + ] |
| 20 | + }, |
| 21 | + { |
| 22 | + "cell_type": "code", |
| 23 | + "execution_count": 1, |
| 24 | + "metadata": {}, |
| 25 | + "outputs": [ |
| 26 | + { |
| 27 | + "data": { |
| 28 | + "text/plain": [ |
| 29 | + "'3.6.1'" |
| 30 | + ] |
| 31 | + }, |
| 32 | + "execution_count": 1, |
| 33 | + "metadata": {}, |
| 34 | + "output_type": "execute_result" |
| 35 | + } |
| 36 | + ], |
| 37 | + "source": [ |
| 38 | + "import plotly\n", |
| 39 | + "plotly.__version__" |
| 40 | + ] |
| 41 | + }, |
13 | 42 | {
|
14 | 43 | "cell_type": "markdown",
|
15 | 44 | "metadata": {},
|
|
29 | 58 | },
|
30 | 59 | {
|
31 | 60 | "cell_type": "code",
|
32 |
| - "execution_count": 1, |
| 61 | + "execution_count": 2, |
33 | 62 | "metadata": {},
|
34 | 63 | "outputs": [
|
35 | 64 | {
|
36 | 65 | "data": {
|
37 | 66 | "text/html": [
|
38 |
| - "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~jordanpeterson/1067.embed\" height=\"525px\" width=\"100%\"></iframe>" |
| 67 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/3195.embed\" height=\"525px\" width=\"100%\"></iframe>" |
39 | 68 | ],
|
40 | 69 | "text/plain": [
|
41 | 70 | "<plotly.tools.PlotlyDisplay object>"
|
42 | 71 | ]
|
43 | 72 | },
|
44 |
| - "execution_count": 1, |
| 73 | + "execution_count": 2, |
45 | 74 | "metadata": {},
|
46 | 75 | "output_type": "execute_result"
|
47 | 76 | }
|
48 | 77 | ],
|
49 | 78 | "source": [
|
50 | 79 | "import plotly.plotly as py\n",
|
| 80 | + "import plotly.graph_objs as go\n", |
51 | 81 | "\n",
|
52 | 82 | "import pandas as pd\n",
|
53 | 83 | "\n",
|
|
63 | 93 | "for i in range(len(limits)):\n",
|
64 | 94 | " lim = limits[i]\n",
|
65 | 95 | " df_sub = df[lim[0]:lim[1]]\n",
|
66 |
| - " city = dict(\n", |
67 |
| - " type = 'scattergeo',\n", |
| 96 | + " city = go.Scattergeo(\n", |
68 | 97 | " locationmode = 'USA-states',\n",
|
69 | 98 | " lon = df_sub['lon'],\n",
|
70 | 99 | " lat = df_sub['lat'],\n",
|
71 | 100 | " text = df_sub['text'],\n",
|
72 |
| - " marker = dict(\n", |
| 101 | + " marker = go.scattergeo.Marker(\n", |
73 | 102 | " size = df_sub['pop']/scale,\n",
|
74 |
| - " # sizeref = 2. * max(df_sub['pop']/scale) / (25 ** 2),\n", |
75 | 103 | " color = colors[i],\n",
|
76 |
| - " line = dict(width=0.5, color='rgb(40,40,40)'),\n", |
| 104 | + " line = go.scattergeo.marker.Line(\n", |
| 105 | + " width=0.5, color='rgb(40,40,40)'\n", |
| 106 | + " ),\n", |
77 | 107 | " sizemode = 'area'\n",
|
78 | 108 | " ),\n",
|
79 | 109 | " name = '{0} - {1}'.format(lim[0],lim[1]) )\n",
|
80 | 110 | " cities.append(city)\n",
|
81 | 111 | "\n",
|
82 |
| - "layout = dict(\n", |
83 |
| - " title = '2014 US city populations<br>(Click legend to toggle traces)',\n", |
| 112 | + "layout = go.Layout(\n", |
| 113 | + " title = go.layout.Title(\n", |
| 114 | + " text = '2014 US city populations<br>(Click legend to toggle traces)'\n", |
| 115 | + " ),\n", |
84 | 116 | " showlegend = True,\n",
|
85 |
| - " geo = dict(\n", |
86 |
| - " scope='usa',\n", |
87 |
| - " projection=dict( type='albers usa' ),\n", |
| 117 | + " geo = go.layout.Geo(\n", |
| 118 | + " scope = 'usa',\n", |
| 119 | + " projection = go.layout.geo.Projection(\n", |
| 120 | + " type='albers usa'\n", |
| 121 | + " ),\n", |
88 | 122 | " showland = True,\n",
|
89 | 123 | " landcolor = 'rgb(217, 217, 217)',\n",
|
90 | 124 | " subunitwidth=1,\n",
|
91 | 125 | " countrywidth=1,\n",
|
92 | 126 | " subunitcolor=\"rgb(255, 255, 255)\",\n",
|
93 | 127 | " countrycolor=\"rgb(255, 255, 255)\"\n",
|
94 |
| - " ),\n", |
| 128 | + " )\n", |
95 | 129 | " )\n",
|
96 | 130 | "\n",
|
97 |
| - "fig = dict(data=cities, layout=layout)\n", |
98 |
| - "py.iplot(fig, validate=False, filename='d3-bubble-map-populations')" |
| 131 | + "fig = go.Figure(data=cities, layout=layout)\n", |
| 132 | + "py.iplot(fig, filename='d3-bubble-map-populations')" |
99 | 133 | ]
|
100 | 134 | },
|
101 | 135 | {
|
|
107 | 141 | },
|
108 | 142 | {
|
109 | 143 | "cell_type": "code",
|
110 |
| - "execution_count": 1, |
| 144 | + "execution_count": 3, |
111 | 145 | "metadata": {},
|
112 | 146 | "outputs": [
|
113 | 147 | {
|
114 | 148 | "data": {
|
115 | 149 | "text/html": [
|
116 |
| - "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~jordanpeterson/1144.embed\" height=\"525px\" width=\"100%\"></iframe>" |
| 150 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/2921.embed\" height=\"525px\" width=\"100%\"></iframe>" |
117 | 151 | ],
|
118 | 152 | "text/plain": [
|
119 | 153 | "<plotly.tools.PlotlyDisplay object>"
|
120 | 154 | ]
|
121 | 155 | },
|
122 |
| - "execution_count": 1, |
| 156 | + "execution_count": 3, |
123 | 157 | "metadata": {},
|
124 | 158 | "output_type": "execute_result"
|
125 | 159 | }
|
|
143 | 177 | " lat = df[ df['Month'] == i ]['Lat'],\n",
|
144 | 178 | " text = df[ df['Month'] == i ]['Value'],\n",
|
145 | 179 | " name = months[i],\n",
|
146 |
| - " marker = dict(\n", |
| 180 | + " marker = go.scattergeo.Marker(\n", |
147 | 181 | " size = df[ df['Month'] == i ]['Value']/50,\n",
|
148 | 182 | " color = colors[i-6],\n",
|
149 |
| - " line = dict(width = 0)\n", |
| 183 | + " line = go.scattergeo.marker.Line(width = 0)\n", |
150 | 184 | " )\n",
|
151 | 185 | " )\n",
|
152 | 186 | " )\n",
|
|
178 | 212 | "]\n",
|
179 | 213 | "\n",
|
180 | 214 | "layout = go.Layout(\n",
|
181 |
| - " title = 'Ebola cases reported by month in West Africa 2014<br> \\\n", |
| 215 | + " title = go.layout.Title(\n", |
| 216 | + " text = 'Ebola cases reported by month in West Africa 2014<br> \\\n", |
182 | 217 | "Source: <a href=\"https://data.hdx.rwlabs.org/dataset/rowca-ebola-cases\">\\\n",
|
183 |
| - "HDX</a>',\n", |
184 |
| - " geo = dict(\n", |
| 218 | + "HDX</a>'),\n", |
| 219 | + " geo = go.layout.Geo(\n", |
185 | 220 | " resolution = 50,\n",
|
186 | 221 | " scope = 'africa',\n",
|
187 | 222 | " showframe = False,\n",
|
|
190 | 225 | " landcolor = \"rgb(229, 229, 229)\",\n",
|
191 | 226 | " countrycolor = \"rgb(255, 255, 255)\" ,\n",
|
192 | 227 | " coastlinecolor = \"rgb(255, 255, 255)\",\n",
|
193 |
| - " projection = dict(\n", |
| 228 | + " projection = go.layout.geo.Projection(\n", |
194 | 229 | " type = 'mercator'\n",
|
195 | 230 | " ),\n",
|
196 |
| - " lonaxis = dict( range= [ -15.0, -5.0 ] ),\n", |
197 |
| - " lataxis = dict( range= [ 0.0, 12.0 ] ),\n", |
198 |
| - " domain = dict(\n", |
| 231 | + " lonaxis = go.layout.geo.Lonaxis(\n", |
| 232 | + " range= [ -15.0, -5.0 ]\n", |
| 233 | + " ),\n", |
| 234 | + " lataxis = go.layout.geo.Lataxis(\n", |
| 235 | + " range= [ 0.0, 12.0 ]\n", |
| 236 | + " ),\n", |
| 237 | + " domain = go.layout.geo.Domain(\n", |
199 | 238 | " x = [ 0, 1 ],\n",
|
200 | 239 | " y = [ 0, 1 ]\n",
|
201 | 240 | " )\n",
|
202 | 241 | " ),\n",
|
203 |
| - " geo2 = dict(\n", |
| 242 | + " geo2 = go.layout.Geo(\n", |
204 | 243 | " scope = 'africa',\n",
|
205 | 244 | " showframe = False,\n",
|
206 | 245 | " showland = True,\n",
|
207 | 246 | " landcolor = \"rgb(229, 229, 229)\",\n",
|
208 | 247 | " showcountries = False,\n",
|
209 |
| - " domain = dict(\n", |
| 248 | + " domain = go.layout.geo.Domain(\n", |
210 | 249 | " x = [ 0, 0.6 ],\n",
|
211 | 250 | " y = [ 0, 0.6 ]\n",
|
212 | 251 | " ),\n",
|
213 | 252 | " bgcolor = 'rgba(255, 255, 255, 0.0)',\n",
|
214 | 253 | " ),\n",
|
215 |
| - " legend = dict(\n", |
| 254 | + " legend = go.layout.Legend(\n", |
216 | 255 | " traceorder = 'reversed'\n",
|
217 | 256 | " )\n",
|
218 | 257 | ")\n",
|
219 | 258 | "\n",
|
220 | 259 | "fig = go.Figure(layout=layout, data=cases+inset)\n",
|
221 |
| - "py.iplot(fig, validate=False, filename='West Africa Ebola cases 2014')" |
| 260 | + "py.iplot(fig, filename='West Africa Ebola cases 2014')" |
222 | 261 | ]
|
223 | 262 | },
|
224 | 263 | {
|
|
231 | 270 | },
|
232 | 271 | {
|
233 | 272 | "cell_type": "code",
|
234 |
| - "execution_count": 2, |
| 273 | + "execution_count": 5, |
235 | 274 | "metadata": {},
|
236 | 275 | "outputs": [
|
237 | 276 | {
|
|
263 | 302 | "output_type": "stream",
|
264 | 303 | "text": [
|
265 | 304 | "Collecting git+https://github.com/plotly/publisher.git\n",
|
266 |
| - " Cloning https://github.com/plotly/publisher.git to /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-req-build-s5ETWe\n", |
| 305 | + " Cloning https://github.com/plotly/publisher.git to c:\\users\\priyat~1\\appdata\\local\\temp\\pip-req-build-4lf8_u0r\n", |
267 | 306 | "Building wheels for collected packages: publisher\n",
|
268 |
| - " Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n", |
269 |
| - "\u001b[?25h Stored in directory: /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-ephem-wheel-cache-muSfgQ/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", |
| 307 | + " Running setup.py bdist_wheel for publisher: started\n", |
| 308 | + " Running setup.py bdist_wheel for publisher: finished with status 'done'\n", |
| 309 | + " Stored in directory: C:\\Users\\PRIYAT~1\\AppData\\Local\\Temp\\pip-ephem-wheel-cache-rulskn3k\\wheels\\99\\3e\\a0\\fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", |
270 | 310 | "Successfully built publisher\n",
|
271 | 311 | "Installing collected packages: publisher\n",
|
272 |
| - " Found existing installation: publisher 0.11\n", |
273 |
| - " Uninstalling publisher-0.11:\n", |
274 |
| - " Successfully uninstalled publisher-0.11\n", |
275 |
| - "Successfully installed publisher-0.11\n" |
276 |
| - ] |
277 |
| - }, |
278 |
| - { |
279 |
| - "name": "stderr", |
280 |
| - "output_type": "stream", |
281 |
| - "text": [ |
282 |
| - "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning:\n", |
283 |
| - "\n", |
284 |
| - "The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n", |
285 |
| - "\n", |
286 |
| - "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning:\n", |
287 |
| - "\n", |
288 |
| - "Did you \"Save\" this notebook before running this command? Remember to save, always save.\n", |
289 |
| - "\n" |
| 312 | + " Found existing installation: publisher 0.13\n", |
| 313 | + " Uninstalling publisher-0.13:\n", |
| 314 | + " Successfully uninstalled publisher-0.13\n", |
| 315 | + "Successfully installed publisher-0.13\n" |
290 | 316 | ]
|
291 | 317 | }
|
292 | 318 | ],
|
|
305 | 331 | " has_thumbnail='true', thumbnail='thumbnail/bubble-map.jpg',\n",
|
306 | 332 | " language='python',\n",
|
307 | 333 | " page_type='example_index',\n",
|
308 |
| - " display_as='maps', order=3, # ipynb='~notebook_demo/1',\n", |
| 334 | + " display_as='maps', order=3,\n", |
309 | 335 | " uses_plotly_offline=False)"
|
310 | 336 | ]
|
311 | 337 | },
|
|
319 | 345 | ],
|
320 | 346 | "metadata": {
|
321 | 347 | "kernelspec": {
|
322 |
| - "display_name": "Python 2", |
| 348 | + "display_name": "Python 3", |
323 | 349 | "language": "python",
|
324 |
| - "name": "python2" |
| 350 | + "name": "python3" |
325 | 351 | },
|
326 | 352 | "language_info": {
|
327 | 353 | "codemirror_mode": {
|
328 | 354 | "name": "ipython",
|
329 |
| - "version": 2 |
| 355 | + "version": 3 |
330 | 356 | },
|
331 | 357 | "file_extension": ".py",
|
332 | 358 | "mimetype": "text/x-python",
|
333 | 359 | "name": "python",
|
334 | 360 | "nbconvert_exporter": "python",
|
335 |
| - "pygments_lexer": "ipython2", |
336 |
| - "version": "2.7.12" |
| 361 | + "pygments_lexer": "ipython3", |
| 362 | + "version": "3.7.1" |
337 | 363 | }
|
338 | 364 | },
|
339 | 365 | "nbformat": 4,
|
|
0 commit comments