SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: zunbeltz <zun...@gm...> - 2014年06月27日 07:59:45
I have a script that fetchs data from a database and plot using 
something similar to
fig, (ax1, ax3) = plt.subplots(2, 1, sharex=False, sharey=False, num=fignum)
ax1.errorbar(...)
title(...)
ax2 = ax1.twiny()
ax4 = ax2.twiny()
...
plt.legent()
plt.draw()
Then, I call this script with plt.ion() and I use plt.show(block=True); 
so the plot stays opened.
Now, I want to rerun the script every second to get the updated data 
from the database. Is it posible to have the plot no blocking the script 
and being refresh?
I try to use block=False but this makes that the plot is not shown. I 
want to change my original script as little as possible. One posible 
idea I have is to pickle the plot (in the original script); and use 
another script that opens the pickled file every second.
TIA
Zunbeltz
(posted unsuccessfully at stackoverflow)
From: Eric F. <ef...@ha...> - 2014年06月28日 07:20:54
On 2014年06月27日, 9:59 AM, zunbeltz wrote:
> I have a script that fetchs data from a database and plot using
> something similar to
>
> fig, (ax1, ax3) = plt.subplots(2, 1, sharex=False, sharey=False, num=fignum)
> ax1.errorbar(...)
> title(...)
> ax2 = ax1.twiny()
> ax4 = ax2.twiny()
> ...
> plt.legent()
> plt.draw()
>
> Then, I call this script with plt.ion() and I use plt.show(block=True);
> so the plot stays opened.
>
> Now, I want to rerun the script every second to get the updated data
> from the database. Is it posible to have the plot no blocking the script
> and being refresh?
You might find that plt.pause(1) is helpful.
See pylab_examples/animation_demo.py.
Also, it sounds like running via ipython, if possible, would make things 
easier for you; it takes care of all sorts of difficulties with 
interactivity. And it's wonderfully helpful in other ways as well.
>
> I try to use block=False but this makes that the plot is not shown. I
> want to change my original script as little as possible. One posible
> idea I have is to pickle the plot (in the original script); and use
> another script that opens the pickled file every second.
That sounds overly complex and roundabout. I'm sure that one or more of 
the suggestions above can lead to a simple solution.
Eric
>
> TIA
>
> Zunbeltz
> (posted unsuccessfully at stackoverflow)
>
>
> ------------------------------------------------------------------------------
> Open source business process management suite built on Java and Eclipse
> Turn processes into business applications with Bonita BPM Community Edition
> Quickly connect people, data, and systems into organized workflows
> Winner of BOSSIE, CODIE, OW2 and Gartner awards
> http://p.sf.net/sfu/Bonitasoft
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /