On Thu, Jun 19, 2008 at 1:40 PM, Daniel Ashbrook <[EMAIL PROTECTED]> wrote:
> I need to have a plot window hang around and be occasionally updated by
> my script as it does things. I've been looking through examples and have
> not been able to get anything to work.
>
> My current approach, inspired by strip_chart_demo.py and others in the
> animation examples, is:

Use the gtk mainloop and do your figure updates in a timeout add or a
idle handler (as suggested in the animation tutorial at
http://www.scipy.org/Cookbook/Matplotlib/Animations

import gobject
import numpy as np
import matplotlib
matplotlib.use('GTKAgg')

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)

def update():
    line.set_ydata(np.random.rand(10))
    fig.canvas.draw_idle()
    return True  # return False to terminate the updates

gobject.timeout_add(100, update)  # you can also use idle_add to
update when gtk is idle
plt.show()

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to