|
14 | 14 | "cell_type": "markdown",
|
15 | 15 | "metadata": {},
|
16 | 16 | "source": [
|
17 |
| - "### United States Choropleth Map" |
| 17 | + "#### United States Choropleth Map" |
18 | 18 | ]
|
19 | 19 | },
|
20 | 20 | {
|
21 | 21 | "cell_type": "code",
|
22 | 22 | "execution_count": 1,
|
23 |
| - "metadata": { |
24 |
| - "collapsed": false |
25 |
| - }, |
| 23 | + "metadata": {}, |
26 | 24 | "outputs": [
|
27 | 25 | {
|
28 | 26 | "data": {
|
29 | 27 | "text/html": [
|
30 |
| - "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~chelsea_lyn/7898.embed\" height=\"525px\" width=\"100%\"></iframe>" |
| 28 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~AdamKulidjian/6694.embed\" height=\"525px\" width=\"100%\"></iframe>" |
31 | 29 | ],
|
32 | 30 | "text/plain": [
|
33 | 31 | "<plotly.tools.PlotlyDisplay object>"
|
|
89 | 87 | "cell_type": "markdown",
|
90 | 88 | "metadata": {},
|
91 | 89 | "source": [
|
92 |
| - "### World Choropleth Map" |
| 90 | + "#### World Choropleth Map" |
93 | 91 | ]
|
94 | 92 | },
|
95 | 93 | {
|
96 | 94 | "cell_type": "code",
|
97 | 95 | "execution_count": 2,
|
98 |
| - "metadata": { |
99 |
| - "collapsed": false |
100 |
| - }, |
| 96 | + "metadata": {}, |
101 | 97 | "outputs": [
|
102 | 98 | {
|
103 | 99 | "data": {
|
104 | 100 | "text/html": [
|
105 |
| - "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~chelsea_lyn/7903.embed\" height=\"525px\" width=\"100%\"></iframe>" |
| 101 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~AdamKulidjian/6696.embed\" height=\"525px\" width=\"100%\"></iframe>" |
106 | 102 | ],
|
107 | 103 | "text/plain": [
|
108 | 104 | "<plotly.tools.PlotlyDisplay object>"
|
|
160 | 156 | "cell_type": "markdown",
|
161 | 157 | "metadata": {},
|
162 | 158 | "source": [
|
163 |
| - "### Choropleth Inset Map" |
| 159 | + "#### Choropleth Inset Map" |
164 | 160 | ]
|
165 | 161 | },
|
166 | 162 | {
|
167 | 163 | "cell_type": "code",
|
168 | 164 | "execution_count": 3,
|
169 |
| - "metadata": { |
170 |
| - "collapsed": false |
171 |
| - }, |
| 165 | + "metadata": {}, |
172 | 166 | "outputs": [
|
173 | 167 | {
|
174 | 168 | "data": {
|
175 | 169 | "text/html": [
|
176 |
| - "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~chelsea_lyn/13235.embed\" height=\"525px\" width=\"100%\"></iframe>" |
| 170 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~AdamKulidjian/6698.embed\" height=\"525px\" width=\"100%\"></iframe>" |
177 | 171 | ],
|
178 | 172 | "text/plain": [
|
179 | 173 | "<plotly.tools.PlotlyDisplay object>"
|
|
276 | 270 | ")\n",
|
277 | 271 | "\n",
|
278 | 272 | "fig = go.Figure(layout=layout, data=cases+inset)\n",
|
279 |
| - "py.iplot(fig, validate=False, filename='West Africa Ebola cases 2014')\n" |
| 273 | + "py.iplot(fig, validate=False, filename='West Africa Ebola cases 2014')" |
280 | 274 | ]
|
281 | 275 | },
|
282 | 276 | {
|
283 | 277 | "cell_type": "markdown",
|
284 | 278 | "metadata": {},
|
285 | 279 | "source": [
|
286 |
| - "### PACE Approved Legislation " |
| 280 | + "#### Full County Choropleths\n", |
| 281 | + "For the full county choropleth doc page checkout https://plot.ly/python/county-choropleth/" |
287 | 282 | ]
|
288 | 283 | },
|
289 | 284 | {
|
290 | 285 | "cell_type": "code",
|
291 |
| - "execution_count": 1, |
292 |
| - "metadata": { |
293 |
| - "collapsed": false |
294 |
| - }, |
| 286 | + "execution_count": 4, |
| 287 | + "metadata": {}, |
295 | 288 | "outputs": [
|
| 289 | + { |
| 290 | + "name": "stdout", |
| 291 | + "output_type": "stream", |
| 292 | + "text": [ |
| 293 | + "The draw time for this plot will be slow for clients without much RAM.\n" |
| 294 | + ] |
| 295 | + }, |
| 296 | + { |
| 297 | + "name": "stderr", |
| 298 | + "output_type": "stream", |
| 299 | + "text": [ |
| 300 | + "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/api/v1/clientresp.py:40: UserWarning:\n", |
| 301 | + "\n", |
| 302 | + "Estimated Draw Time Slow\n", |
| 303 | + "\n" |
| 304 | + ] |
| 305 | + }, |
296 | 306 | {
|
297 | 307 | "data": {
|
298 | 308 | "text/html": [
|
299 |
| - "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~Diksha_Gabha/2513.embed\" height=\"525px\" width=\"800px\"></iframe>" |
| 309 | + "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~AdamKulidjian/6672.embed\" height=\"450px\" width=\"900px\"></iframe>" |
300 | 310 | ],
|
301 | 311 | "text/plain": [
|
302 | 312 | "<plotly.tools.PlotlyDisplay object>"
|
303 | 313 | ]
|
304 | 314 | },
|
305 |
| - "execution_count": 1, |
| 315 | + "execution_count": 4, |
306 | 316 | "metadata": {},
|
307 | 317 | "output_type": "execute_result"
|
308 | 318 | }
|
309 | 319 | ],
|
310 | 320 | "source": [
|
311 | 321 | "import plotly.plotly as py\n",
|
312 |
| - "from plotly.graph_objs import *\n", |
| 322 | + "import plotly.figure_factory as ff\n", |
313 | 323 | "\n",
|
314 |
| - "trace1 = Choropleth(\n", |
315 |
| - " z=['1', '1', '1', '1', '1', '1', '1'],\n", |
316 |
| - " autocolorscale=False,\n", |
317 |
| - " colorscale=[[0, 'rgb(255,255,255)'], [1, 'rgb(186,58,51)']],\n", |
318 |
| - " hoverinfo='text',\n", |
319 |
| - " locationmode='USA-states',\n", |
320 |
| - " locations=['AR', 'GA', 'KY', 'MO', 'UT', 'TX', 'WY'],\n", |
321 |
| - " name='Republican',\n", |
322 |
| - " showscale=False,\n", |
323 |
| - " text=['Arkansas', 'Georgia', 'Kentucky', 'Missouri', 'Utah', 'Texas', 'Wyoming'],\n", |
324 |
| - " zauto=False,\n", |
325 |
| - " zmax=1,\n", |
326 |
| - " zmin=0,\n", |
327 |
| - ")\n", |
328 |
| - "trace2 = Choropleth(\n", |
329 |
| - " z=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],\n", |
330 |
| - " autocolorscale=False,\n", |
331 |
| - " colorscale=[[0, 'rgb(255,255,255)'], [1, 'rgb(68,94,150)']],\n", |
332 |
| - " hoverinfo='text',\n", |
333 |
| - " locationmode='USA-states',\n", |
334 |
| - " locations=['CA', 'CI', 'DOC', 'IL', 'MD', 'NJ', 'NM', 'NY', 'OR', 'RI', 'VT'],\n", |
335 |
| - " name='Democrat',\n", |
336 |
| - " showscale=False,\n", |
337 |
| - " text=['California', 'Connecticut', 'District of Columbia', 'Illinois', \n", |
338 |
| - " 'Maryland', 'New Jersey', 'New Mexico', 'New York', 'Oregon',\n", |
339 |
| - " 'Rhode Island', 'Vermont'],\n", |
340 |
| - " zauto=False,\n", |
341 |
| - " zmax=1,\n", |
342 |
| - " zmin=0,\n", |
343 |
| - ")\n", |
344 |
| - "trace3 = Choropleth(\n", |
345 |
| - " z=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],\n", |
346 |
| - " autocolorscale=False,\n", |
347 |
| - " colorscale=[[0, 'rgb(255, 255, 255)'], [1, 'rgb(187, 170, 144)']],\n", |
348 |
| - " hoverinfo='text',\n", |
349 |
| - " locationmode='USA-states',\n", |
350 |
| - " locations=['CO', 'FL', 'MI', 'MN', 'NH', 'OH', 'VA', 'WI'],\n", |
351 |
| - " name='Swing State',\n", |
352 |
| - " showscale=False,\n", |
353 |
| - " text=['Colorado', 'Florida', 'Michigan', 'Minnesota', \n", |
354 |
| - " 'New Hampshire', 'Ohio', 'Virginia', 'Wisconsin'],\n", |
355 |
| - " zauto=False,\n", |
356 |
| - " zmax=1,\n", |
357 |
| - " zmin=0,\n", |
358 |
| - ")\n", |
| 324 | + "import numpy as np\n", |
| 325 | + "import pandas as pd\n", |
359 | 326 | "\n",
|
360 |
| - "data = Data([trace1, trace2, trace3])\n", |
361 |
| - "layout = Layout(\n", |
362 |
| - " autosize=False,\n", |
363 |
| - " geo=dict(\n", |
364 |
| - " countrycolor='rgb(102, 102, 102)',\n", |
365 |
| - " countrywidth=0.1,\n", |
366 |
| - " lakecolor='rgb(255, 255, 255)',\n", |
367 |
| - " landcolor='rgba(237, 247, 138, 0.28)',\n", |
368 |
| - " lonaxis=dict(\n", |
369 |
| - " gridwidth=1.5999999999999999,\n", |
370 |
| - " range=[-180, -50],\n", |
371 |
| - " showgrid=False\n", |
372 |
| - " ),\n", |
373 |
| - " projection=dict(\n", |
374 |
| - " type='albers usa'\n", |
375 |
| - " ),\n", |
376 |
| - " scope='usa',\n", |
377 |
| - " showland=True,\n", |
378 |
| - " showrivers=False,\n", |
379 |
| - " showsubunits=True,\n", |
380 |
| - " subunitcolor='rgb(102, 102, 102)',\n", |
381 |
| - " subunitwidth=0.5\n", |
382 |
| - " ),\n", |
383 |
| - " hovermode='closest',\n", |
384 |
| - " images=list([\n", |
385 |
| - " dict(\n", |
386 |
| - " x=1,\n", |
387 |
| - " y=0.6,\n", |
388 |
| - " sizex=0.155,\n", |
389 |
| - " sizey=0.4,\n", |
390 |
| - " source='http://i.imgur.com/Xe3f1zg.png',\n", |
391 |
| - " xanchor='right',\n", |
392 |
| - " xref='paper',\n", |
393 |
| - " yanchor='bottom',\n", |
394 |
| - " yref='paper'\n", |
395 |
| - " )\n", |
396 |
| - " ]),\n", |
397 |
| - " showlegend=True,\n", |
398 |
| - " title='<b>PACE Approved legislation</b>',\n", |
399 |
| - " width= 800,\n", |
400 |
| - " margin = dict(\n", |
401 |
| - " l=0,\n", |
402 |
| - " r=50,\n", |
403 |
| - " b=100,\n", |
404 |
| - " t=100,\n", |
405 |
| - " pad=4)\n", |
| 327 | + "df_sample = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/laucnty16.csv')\n", |
| 328 | + "df_sample['State FIPS Code'] = df_sample['State FIPS Code'].apply(lambda x: str(x).zfill(2))\n", |
| 329 | + "df_sample['County FIPS Code'] = df_sample['County FIPS Code'].apply(lambda x: str(x).zfill(3))\n", |
| 330 | + "df_sample['FIPS'] = df_sample['State FIPS Code'] + df_sample['County FIPS Code']\n", |
| 331 | + "\n", |
| 332 | + "colorscale = [\"#f7fbff\",\"#ebf3fb\",\"#deebf7\",\"#d2e3f3\",\"#c6dbef\",\"#b3d2e9\",\"#9ecae1\",\n", |
| 333 | + " \"#85bcdb\",\"#6baed6\",\"#57a0ce\",\"#4292c6\",\"#3082be\",\"#2171b5\",\"#1361a9\",\n", |
| 334 | + " \"#08519c\",\"#0b4083\",\"#08306b\"]\n", |
| 335 | + "endpts = list(np.linspace(1, 12, len(colorscale) - 1))\n", |
| 336 | + "fips = df_sample['FIPS'].tolist()\n", |
| 337 | + "values = df_sample['Unemployment Rate (%)'].tolist()\n", |
| 338 | + "\n", |
| 339 | + "fig = ff.create_choropleth(\n", |
| 340 | + " fips=fips, values=values, scope=['usa'],\n", |
| 341 | + " binning_endpoints=endpts, colorscale=colorscale,\n", |
| 342 | + " show_state_data=False,\n", |
| 343 | + " show_hover=True, centroid_marker={'opacity': 0},\n", |
| 344 | + " asp=2.9, title='USA by Unemployment %',\n", |
| 345 | + " legend_title='% unemployed'\n", |
406 | 346 | ")\n",
|
407 |
| - "fig = Figure(data=data, layout=layout)\n", |
408 |
| - "py.iplot(fig, filename='pace')" |
| 347 | + "py.iplot(fig, filename='choropleth_full_usa')" |
409 | 348 | ]
|
410 | 349 | },
|
411 | 350 | {
|
|
418 | 357 | },
|
419 | 358 | {
|
420 | 359 | "cell_type": "code",
|
421 |
| -<<<<<<< HEAD |
422 | 360 | "execution_count": 1,
|
423 |
| -======= |
424 |
| - "execution_count": 2, |
425 |
| ->>>>>>> b22a31ab6cd91d151ab51741f3fcb448574008a5 |
426 |
| - "metadata": { |
427 |
| - "collapsed": false |
428 |
| - }, |
| 361 | + "metadata": {}, |
429 | 362 | "outputs": [
|
430 | 363 | {
|
431 | 364 | "data": {
|
|
456 | 389 | "output_type": "stream",
|
457 | 390 | "text": [
|
458 | 391 | "Collecting git+https://github.com/plotly/publisher.git\n",
|
459 |
| -<<<<<<< HEAD |
460 |
| - " Cloning https://github.com/plotly/publisher.git to /var/folders/ld/6cl3s_l50wd40tdjq2b03jxh0000gp/T/pip-k8JnpP-build\n", |
| 392 | + " Cloning https://github.com/plotly/publisher.git to /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-OKLJ7r-build\n", |
461 | 393 | "Installing collected packages: publisher\n",
|
462 | 394 | " Found existing installation: publisher 0.11\n",
|
463 | 395 | " Uninstalling publisher-0.11:\n",
|
464 | 396 | " Successfully uninstalled publisher-0.11\n",
|
465 |
| - " Running setup.py install for publisher ... \u001b[?25l-\b \b\\\b \bdone\n", |
466 |
| - "\u001b[?25hSuccessfully installed publisher-0.10\n" |
467 |
| -======= |
468 |
| - " Cloning https://github.com/plotly/publisher.git to /tmp/pip-ittp0v-build\n", |
469 |
| - "Installing collected packages: publisher\n", |
470 |
| - " Running setup.py install for publisher ... \u001b[?25l-\b \berror\n", |
471 |
| - " Complete output from command /usr/bin/python -u -c \"import setuptools, tokenize;__file__='/tmp/pip-ittp0v-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))\" install --record /tmp/pip-lGFm1Y-record/install-record.txt --single-version-externally-managed --compile:\n", |
472 |
| - " running install\n", |
473 |
| - " running build\n", |
474 |
| - " running build_py\n", |
475 |
| - " creating build\n", |
476 |
| - " creating build/lib.linux-x86_64-2.7\n", |
477 |
| - " creating build/lib.linux-x86_64-2.7/publisher\n", |
478 |
| - " copying publisher/publisher.py -> build/lib.linux-x86_64-2.7/publisher\n", |
479 |
| - " copying publisher/__init__.py -> build/lib.linux-x86_64-2.7/publisher\n", |
480 |
| - " running install_lib\n", |
481 |
| - " creating /usr/local/lib/python2.7/dist-packages/publisher\n", |
482 |
| - " error: could not create '/usr/local/lib/python2.7/dist-packages/publisher': Permission denied\n", |
483 |
| - " \n", |
484 |
| - " ----------------------------------------\n", |
485 |
| - "\u001b[31mCommand \"/usr/bin/python -u -c \"import setuptools, tokenize;__file__='/tmp/pip-ittp0v-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))\" install --record /tmp/pip-lGFm1Y-record/install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in /tmp/pip-ittp0v-build/\u001b[0m\n", |
486 |
| - "\u001b[?25h" |
487 |
| - ] |
488 |
| - }, |
489 |
| - { |
490 |
| - "name": "stderr", |
491 |
| - "output_type": "stream", |
492 |
| - "text": [ |
493 |
| - "/home/diksha/anaconda2/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning:\n", |
494 |
| - "\n", |
495 |
| - "The `IPython.nbconvert` package has been deprecated. You should import from nbconvert instead.\n", |
496 |
| - "\n", |
497 |
| - "/home/diksha/anaconda2/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning:\n", |
498 |
| - "\n", |
499 |
| - "Did you \"Save\" this notebook before running this command? Remember to save, always save.\n", |
500 |
| - "\n" |
501 |
| ->>>>>>> b22a31ab6cd91d151ab51741f3fcb448574008a5 |
| 397 | + " Running setup.py install for publisher ... \u001b[?25ldone\n", |
| 398 | + "\u001b[?25hSuccessfully installed publisher-0.11\n" |
502 | 399 | ]
|
503 | 400 | },
|
504 | 401 | {
|
505 | 402 | "name": "stderr",
|
506 | 403 | "output_type": "stream",
|
507 | 404 | "text": [
|
508 |
| - "/Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated. You should import from nbconvert instead.\n", |
| 405 | + "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n", |
509 | 406 | " \"You should import from nbconvert instead.\", ShimWarning)\n",
|
510 |
| - "/Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you \"Save\" this notebook before running this command? Remember to save, always save.\n", |
| 407 | + "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you \"Save\" this notebook before running this command? Remember to save, always save.\n", |
511 | 408 | " warnings.warn('Did you \"Save\" this notebook before running this command? '\n"
|
512 | 409 | ]
|
513 | 410 | }
|
|
521 | 418 | "! pip install git+https://github.com/plotly/publisher.git --upgrade\n",
|
522 | 419 | "import publisher\n",
|
523 | 420 | "publisher.publish(\n",
|
524 |
| - " 'Choropleth_maps.ipynb', 'python/choropleth-maps/', 'Choropleth Maps | plotly',\n", |
525 |
| - " 'How to make Choropleth maps in Python with Plotly.',\n", |
526 |
| - " title = 'Choropleth Maps | plotly',\n", |
527 |
| - " name = 'Choropleth Maps',\n", |
| 421 | + " 'Choropleth_maps.ipynb', 'python/choropleth-maps/', 'Choropleth Maps',\n", |
| 422 | + " 'How to make choropleth maps in Python with Plotly.',\n", |
| 423 | + " title = 'Python Choropleth Maps | Plotly',\n", |
528 | 424 | " has_thumbnail='true', thumbnail='thumbnail/choropleth.jpg', \n",
|
529 |
| - " language='python', page_type='example_index',\n", |
530 |
| - " display_as='maps', order=1,\n", |
531 |
| - " ipynb= '~notebook_demo/55')" |
| 425 | + " language='python',\n", |
| 426 | + " display_as='maps', order=1, ipynb='~notebook_demo/55',\n", |
| 427 | + " uses_plotly_offline=False)" |
532 | 428 | ]
|
533 | 429 | },
|
534 | 430 | {
|
|
542 | 438 | }
|
543 | 439 | ],
|
544 | 440 | "metadata": {
|
545 |
| - "anaconda-cloud": {}, |
546 | 441 | "kernelspec": {
|
547 | 442 | "display_name": "Python 2",
|
548 | 443 | "language": "python",
|
|
558 | 453 | "name": "python",
|
559 | 454 | "nbconvert_exporter": "python",
|
560 | 455 | "pygments_lexer": "ipython2",
|
561 |
| - "version": "2.7.10" |
| 456 | + "version": "2.7.12" |
562 | 457 | }
|
563 | 458 | },
|
564 | 459 | "nbformat": 4,
|
565 |
| - "nbformat_minor": 0 |
| 460 | + "nbformat_minor": 1 |
566 | 461 | }
|
0 commit comments