We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

event_handling example code: figure_axes_enter_leave.py

Next topic

event_handling example code: keypress_demo.py

This Page

event_handling example code: idle_and_timeout.pyΒΆ

[source code]

from __future__ import print_function
Demonstrate/test the idle and timeout API

This is only tested on gtk so far and is a prototype implementation
import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

t = np.arange(0.0, 2.0, 0.01)
y1 = np.sin(2*np.pi*t)
y2 = np.cos(2*np.pi*t)
line1, = ax.plot(y1)
line2, = ax.plot(y2)

N = 100
def on_idle(event):
    on_idle.count +=1
    print('idle', on_idle.count)
    # test boolean return removal
    if on_idle.count==N:
        return False
    return True
on_idle.cid = None
on_idle.count = 0

fig.canvas.mpl_connect('idle_event', on_idle)


Keywords: python, matplotlib, pylab, example, codex (see Search examples)