SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: darkside <in....@gm...> - 2007年02月28日 21:47:17
Hello,
I'm new in matplotlib, but I have became a fat!
First of all, I have to apologize for my bad English, I hope you can
understand what I mean.
Making some programs I have found the same problem:
> -What I want? I want to plot two sets of changing data using the same
> windows.
> -The problem? My code is:
> -----------------------
> x,y = evol.plot_init()
> pylab.ion()
> pylab.subplot(211)
> line,=pylab.plot(x[0],x[1])
> pylab.draw()
> pylab.ylabel('Posiciones')
> for k in pylab.arange(Nt):
> x, y = evol.plot_step()
> line.set_ydata(x[1])
> pylab.draw()
>
>
> pylab.subplot(212)
> line,=pylab.plot(y[0],y[1])
> pylab.draw()
> pylab.ylabel('Momentos')
>
> for k in pylab.arange(Nt):
> x, y = evol.plot_step()
> line.set_ydata(y[1])
> pylab.draw()
> ---------------------------------------------------------------------
> And if you run this, one draw and anim is done first, you have to wait
> it to stop, and then you can see the other want.
> The thing is that I want that the two anim figures runs at the same time.
>
> Any idea?
>
From: Matthias M. <Mat...@gm...> - 2007年03月01日 09:43:53
Hello darkside,
I set up a little program hoping it offers a solution to your problem.
Matthias
>-------------------------------------------------------------------------------
from numpy.random import uniform 
import pylab 
Nt = 20
x,y = uniform(size=(100,Nt+1)),uniform(size=(100,Nt+1))
pylab.ion()
ax1 = pylab.subplot(211)
pylab.ylabel('Posiciones')
ax2 = pylab.subplot(212)
pylab.ylabel('Momentos')
line1,= ax1.plot(x[:,0], x[:,1])
line2,= ax2.plot(y[:,0], y[:,1])
pylab.draw()
pylab.draw()
# alternative you could use
"""
pylab.axes(ax1)
line1,= pylab.plot(x[:,0], x[:,1])
pylab.axes(ax2)
line2,= pylab.plot(y[:,0], y[:,1])
pylab.draw()
"""
for k in pylab.arange(Nt):
 line1.set_ydata(x[:,k+1])
 line2.set_ydata(y[:,k+1])
 pylab.draw()
 pylab.draw()
pylab.ioff()
pylab.show()
>-------------------------------------------------------------------
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 によって変換されたページ (->オリジナル) /