In [1]:
import matplotlib.pyplot as plt
import numpy as np
from ipywidgets import interact
from ipywidgets.widgets import IntSlider, Dropdown
plt.ion()

Ipywidgets

In [2]:
data = np.logspace(0, 2, 100)
data = np.tile(data, [100, 1])
data += np.random.randn(100, 100) * 50
data += np.linspace(0, 1000, 100)[:, np.newaxis]
In [3]:
cmaps = ['coolwarm', 'viridis', 'magma']
def plot_data(ii, cmap):
    fig, ax = plt.subplots()
    cmap = plt.get_cmap(cmap)
    color = cmap(ii / 100.)
    ax.plot(data[ii], color=color)
    ax.set_ylim([0, 1000])
    plt.show()
    
interact(plot_data, ii=IntSlider(0, 0, 99), cmap=Dropdown(options=cmaps))
Out[3]:
<function __main__.plot_data>

Python-markdown

In [4]:
a = 'markdown!'
b = 2

Double-click this cell, then hit shift+enter

this is {{ a }}

it is {{ b }} cool!