Skip to content

Commit 4422461

Browse files
authored
Fix interactive plots (#91)
1 parent 8d98879 commit 4422461

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

binder/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies:
2929
- seaborn
3030
- holoviews
3131
- geoviews
32+
- hvplot
3233
- pip
3334
- pip:
3435
- joblib

oggm-edu/glacier_water_resources.ipynb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,20 @@
206206
"outputs": [],
207207
"source": [
208208
"# One interactive plot below requires Bokeh\n",
209-
"# The rest of the notebook works without this dependency - comment if needed\n",
210-
"import holoviews as hv\n",
211-
"hv.extension('bokeh')\n",
212-
"import geoviews as gv\n",
213-
"import geoviews.tile_sources as gts\n",
209+
"try:\n",
210+
" import holoviews as hv\n",
211+
" hv.extension('bokeh')\n",
212+
" import geoviews as gv\n",
213+
" import geoviews.tile_sources as gts\n",
214214
"\n",
215-
"sh = salem.transform_geopandas(gdir.read_shapefile('outlines'))\n",
216-
"(gv.Polygons(sh).opts(fill_color=None, color_index=None) *\n",
217-
" gts.tile_sources['EsriImagery'] * gts.tile_sources['StamenLabels']).opts(width=800, height=500, active_tools=['pan', 'wheel_zoom'])"
215+
" sh = salem.transform_geopandas(gdir.read_shapefile('outlines'))\n",
216+
" out = (gv.Polygons(sh).opts(fill_color=None, color_index=None) * \n",
217+
" gts.tile_sources['EsriImagery'] * \n",
218+
" gts.tile_sources['StamenLabels']).opts(width=800, height=500, active_tools=['pan', 'wheel_zoom'])\n",
219+
"except:\n",
220+
" # The rest of the notebook works without this dependency\n",
221+
" out = None\n",
222+
"out"
218223
]
219224
},
220225
{
@@ -804,7 +809,7 @@
804809
"name": "python",
805810
"nbconvert_exporter": "python",
806811
"pygments_lexer": "ipython3",
807-
"version": "3.10.8"
812+
"version": "3.10.9"
808813
},
809814
"toc": {
810815
"base_numbering": 1,

oggm-edu/glacier_water_resources_projections.ipynb

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,31 @@
176176
"outputs": [],
177177
"source": [
178178
"# One interactive plot below requires Bokeh\n",
179-
"# The rest of the notebook works without this dependency - comment if needed\n",
180-
"import holoviews as hv\n",
181-
"hv.extension('bokeh')\n",
182-
"import geoviews as gv\n",
183-
"import geoviews.tile_sources as gts\n",
179+
"try:\n",
180+
" import holoviews as hv\n",
181+
" hv.extension('bokeh')\n",
182+
" import geoviews as gv\n",
183+
" import geoviews.tile_sources as gts\n",
184184
"\n",
185-
"sh = salem.transform_geopandas(gdir.read_shapefile('outlines'))\n",
186-
"(gv.Polygons(sh).opts(fill_color=None, color_index=None) *\n",
187-
" gts.tile_sources['EsriImagery'] * gts.tile_sources['StamenLabels']).opts(width=800, height=500, active_tools=['pan', 'wheel_zoom'])"
185+
" sh = salem.transform_geopandas(gdir.read_shapefile('outlines'))\n",
186+
" out = (gv.Polygons(sh).opts(fill_color=None, color_index=None) * \n",
187+
" gts.tile_sources['EsriImagery'] * \n",
188+
" gts.tile_sources['StamenLabels']).opts(width=800, height=500, active_tools=['pan', 'wheel_zoom'])\n",
189+
"except:\n",
190+
" # The rest of the notebook works without this dependency\n",
191+
" out = None\n",
192+
"out"
193+
]
194+
},
195+
{
196+
"cell_type": "code",
197+
"execution_count": null,
198+
"metadata": {
199+
"tags": []
200+
},
201+
"outputs": [],
202+
"source": [
203+
"type(out)"
188204
]
189205
},
190206
{
@@ -557,9 +573,16 @@
557573
"metadata": {},
558574
"outputs": [],
559575
"source": [
560-
"sh = salem.transform_geopandas(gdirs[1].read_shapefile('outlines'))\n",
561-
"(gv.Polygons(sh).opts(fill_color=None, color_index=None) *\n",
562-
" gts.tile_sources['EsriImagery'] * gts.tile_sources['StamenLabels']).opts(width=800, height=500, active_tools=['pan', 'wheel_zoom'])"
576+
"# One interactive plot below requires Bokeh\n",
577+
"try:\n",
578+
" sh = salem.transform_geopandas(gdirs[1].read_shapefile('outlines'))\n",
579+
" out = (gv.Polygons(sh).opts(fill_color=None, color_index=None) * \n",
580+
" gts.tile_sources['EsriImagery'] *\n",
581+
" gts.tile_sources['StamenLabels']).opts(width=800, height=500, active_tools=['pan', 'wheel_zoom'])\n",
582+
"except:\n",
583+
" # The rest of the notebook works without this dependency\n",
584+
" out = None\n",
585+
"out"
563586
]
564587
},
565588
{
@@ -785,7 +808,7 @@
785808
"name": "python",
786809
"nbconvert_exporter": "python",
787810
"pygments_lexer": "ipython3",
788-
"version": "3.10.8"
811+
"version": "3.10.9"
789812
},
790813
"toc": {
791814
"base_numbering": 1,

0 commit comments

Comments
 (0)