[IPython-dev] Cute example combining IPython.html.widgets.interact and mpld3 zoom/pan.

Dmitry Chichkov dchichkov at gmail.com
Fri May 23 10:56:48 EDT 2014

A cute small example that combines interact and mpld3 zoom/pan. Works with
the current release of ipython-2.1.0, matplotlib-1.3.1 and mpld3-0.3.
It'd be great, if functionality that allows this example to work would stay
and remain operational...

%matplotlib inline
import matplotlib.pyplot as plt, numpy as np
from IPython.html import widgets

import mpld3         # Notice that as you hover over the plot, a toolbar
appears in the lower left.

def on_value_change(value):
    fig, ax = plt.subplots()
    x, y = np.random.normal(size=(2, 100))
    color, size = np.random.random((2, 100))

    ax.scatter(x[:value], y[:value], c=color[:value], s=500 * size,
    ax.grid(color='lightgray', alpha=0.7)

widgets.interact(on_value_change, value = widgets.IntSliderWidget(min=1,

With Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140523/419884d5/attachment.html>

More information about the IPython-dev mailing list