Skip to content

Commit e578d31

Browse files
committed
Work on heat maps.
1 parent 822ad1e commit e578d31

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ venv.bak/
104104
.mypy_cache/
105105

106106
notebooks/my-first-scatter.html
107-
Untitled.ipynb
107+
Untitled*.ipynb
108108
gapminder_gdp_americas.csv

notebooks/03d-plotly-3dviz.ipynb

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,35 @@
3232
"py.init_notebook_mode(connected=False)"
3333
]
3434
},
35+
{
36+
"cell_type": "markdown",
37+
"metadata": {},
38+
"source": [
39+
"People using Colab need this (initialization and download of supporting materials)"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"# Stuff for Colab ...\n",
49+
"import sys\n",
50+
"def enable_plotly_in_cell():\n",
51+
" import IPython\n",
52+
" from plotly.offline import init_notebook_mode\n",
53+
" display(IPython.core.display.HTML('''\n",
54+
" <script src=\"/static/components/requirejs/require.js\"></script>\n",
55+
" '''))\n",
56+
" init_notebook_mode(connected=False)\n",
57+
"\n",
58+
"if 'google.colab' in sys.modules:\n",
59+
" get_ipython().events.register('pre_run_cell', enable_plotly_in_cell)\n",
60+
" !mkdir -p data\n",
61+
" !wget -P data https://raw.githubusercontent.com/ualberta-rcg/python-plotting/master/notebooks/data/gapminder_gdp_europe.csv"
62+
]
63+
},
3564
{
3665
"cell_type": "markdown",
3766
"metadata": {},
@@ -357,11 +386,14 @@
357386
"metadata": {},
358387
"outputs": [],
359388
"source": [
389+
"# Some versions will prefer `z=df.to_numpy()` below\n",
390+
"\n",
360391
"data = [\n",
361392
" go.Heatmap(\n",
362393
" x=years,\n",
363394
" y=df.index,\n",
364395
" z=df,\n",
396+
" colorscale='Jet'\n",
365397
" )\n",
366398
"]\n",
367399
"layout = go.Layout(\n",
@@ -468,7 +500,8 @@
468500
" y=df.index,\n",
469501
" z=df,\n",
470502
" hoverinfo='text',\n",
471-
" text=hovertext\n",
503+
" text=hovertext,\n",
504+
" colorscale='Jet'\n",
472505
" )\n",
473506
"]\n",
474507
"layout = go.Layout(\n",
@@ -493,6 +526,7 @@
493526
" x=years,\n",
494527
" y=df_sorted.index,\n",
495528
" z=df_sorted,\n",
529+
" colorscale='Jet'\n",
496530
" )\n",
497531
"]\n",
498532
"layout = go.Layout(\n",

0 commit comments

Comments
 (0)