In [ ]:
import ipywidgets
import IPython.display
import iris
import numpy as np
import iris.quickplot as iplt
Load cube.
In [ ]:
cube = iris.load_cube(iris.sample_data_path('A1B.2098.pp'))
print cube
Compose lists of options and then construct widgets to present them. In some cases, you can compose the options list inside the parentheses.
Display the widget using the IPython display call.
In [ ]:
cmap_list = ['viridis', 'inferno', 'plasma', 'magma', 'jet', 'summer', 'autumn']
cmap = ipywidgets.Dropdown(
options=cmap_list,
value='jet',
description='cmap:')
extend = ipywidgets.Dropdown(
options=['neither', 'both', 'min', 'max'],
value='both',
description='extend:')
levels = ipywidgets.Text(
description='Levels:',
value='np.linspace(np.min(cube.data), np.max(cube.data), 10)')
IPython.display.display(cmap, extend, levels)
Print selected widget values for clarity.
In [ ]:
print cmap.value
print extend.value
print eval(levels.value)