!date
Sun Feb 2 23:33:08 PST 2014
%matplotlib inline
import matplotlib.pyplot as plt, mpld3
mpld3.enable_notebook("//cdnjs.cloudflare.com/ajax/libs/d3/3.4.1/d3.min.js")
from mpld3 import plugins
fig, ax = plt.subplots()
points = ax.plot([3,1,4,1,5,9,2,6,5,3,5,8], 'o-', color='grey', ms=20, mew=5, linewidth=4)
ax.set_ylim(bottom=-1, top=10)
plugins.connect(fig,
plugins.ResetButton(),
plugins.ConfigurableZoomAndPan(
ax, zoom_y=False, xlim=(-1,15), ylim=(-1,10))
)
Particularly useful when you have a long timeseries:
from sympy.mpmath import mp
mp.dps = 1000 # number of digits
pi = str(mp.pi)
fig, ax = plt.subplots()
points = ax.plot([int(d) for d in pi[2:]], 'o-', color='grey', ms=3, mew=1, linewidth=1)
ax.set_ylim(bottom=-1, top=10)
ax.set_xlim(left=-1, right=100)
plugins.connect(fig,
plugins.ResetButton(),
plugins.ConfigurableZoomAndPan(
ax, zoom_y=False, xlim=(-1,1001), ylim=(-1,10))
)