matplotlib timer

Dave Farrance df at see.replyto.invalid
Thu Oct 1 12:36:50 EDT 2015


I'm trying to set up the basics of a timer-scheduled function in
matplotlib and I can't figure out how to stop the timer. Maybe the
stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
syntax wrong.

If anybody's got matplotlib installed, can you try this code and tell me
if it stops after one tick as it should -- or does it continue printing
every second without stopping as mine does?

#!/usr/bin/env python
import matplotlib.pyplot as P
def fn():
  timer.stop()
  print("tick")
fig, ax = P.subplots()
timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(fn)
timer.start()
P.show()
 



More information about the Python-list mailing list