473,225 Members | 1,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Animations with matplotlib?

I'm trying to make an animation with matplotlib. The problem:
whenever I try to rescale or move the plot with the buttons of
plotting window, the animation stops. My system is Debian Woody and
python-2.3 with matplotlib-0.32. I'm a total newbie with matplotlib
(I installed it yesterday), so what am I doing wrong? An example code
below:

------------------------------------------
#!/usr/bin/env python2.3

import matplotlib.matlab
import gtk
import Numeric

fig = matplotlib.matlab.figure(1)
ind = Numeric.arange(60)
x_tmp=[]
for i in range(100):
x_tmp.append(Numeric.sin((ind+i)*Numeric.pi/15.0))

X=Numeric.array(x_tmp)
lines = matplotlib.matlab.plot(X[:,0],'o')

def updatefig(*args):
updatefig.count += 1
if updatefig.count>59: updatefig.count=0
lines[0].set_data(ind,X[:,updatefig.count])
fig.draw()
return gtk.TRUE

updatefig.count=-1

gtk.timeout_add(200,updatefig)
matplotlib.matlab.show()
-------------------------------------------------

--
Best regards,
Pekko

Jul 18 '05 #1
1 4964
>>>>> "Pekko" == Pekko Piirola <pe***********@helsinki.fi> writes:

Pekko> I'm trying to make an animation with matplotlib. The
Pekko> problem: whenever I try to rescale or move the plot with
Pekko> the buttons of plotting window, the animation stops. My
Pekko> system is Debian Woody and python-2.3 with matplotlib-0.32.
Pekko> I'm a total newbie with matplotlib (I installed it
Pekko> yesterday), so what am I doing wrong? An example code
Pekko> below:

Cute code, looks like the beginnings of a digital oscilloscope....

You have discovered a bug. The Lines2D class goes to great pains to
not plot data outside the view limits and caches a 'clipped' version
of the data set. This cache should have been cleared by the set_data
method. Since set_data is rarely used directly, this bug hasn't been
reported before. It's an easy fix.

In the matplotlib.lines.py module, go to the Line2D.set_data method
(line 74 in the 0.32 release) and replace it with:

def set_data(self, x, y):
try: del self._xc, self._yc
except AttributeError: pass

self._x = asarray(x, Float)
self._y = asarray(y, Float)
if len(self._y)==1 and len(self._x)>1:
self._y = self._y*ones(self._x.shape, Float)

self._xsorted = self._is_sorted(self._x)

The important change is the addition of the first two lines, which
delete the cached instances of the clipped data.

Thanks for the bug report!
John Hunter

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Hunter | last post by:
matplotlib is a 2D plotting package for python with a matlab compatible syntax and output tested under linux and windows platforms. matplotlib-0.30 is available for download at...
3
by: John Hunter | last post by:
matplotlib is a 2D plotting library for python. You can use matplotlib interactively from a python shell or IDE, or embed it in GUI applications (WX, GTK, and Tkinter). matplotlib supports many...
2
by: Grant Edwards | last post by:
I downloaded examples/contour_demo.py, and it doesn't run. I've searched both the user guide and the Wiki for "contour" and got zero hits. ...
0
by: spross | last post by:
hi all i have to use matplotlib on mac os x. on the official site of matplotlib, i found a link to precompiled python packages for mac os x: http://pythonmac.org/packages/py24-fat/index.html ...
0
by: Soren | last post by:
Hi, I've been trying to embed matplotlib in wxpython. I want to be able to put a figure (axes) in a wx.Panel and place it somewhere in my GUI. The GUI should have other panels with buttons etc....
4
by: Bill Jackson | last post by:
Hi, I'm having some trouble plotting with the following matplotlibrc: text.usetex : True I tried clearing the cache files under ~/.matplotlib, but this did not help the problem. I'd post...
3
by: vajratkarviraj | last post by:
i hav python2.5, matplotlib0.90.1, and py2exe for python 2.5 all on windows xp... i hav a python program(letsc.py) which uses the matplotlib package... and i want 2 make an exe of it for distribution...
4
by: John Henry | last post by:
Has anybody been able to create an exe of their python applications involving matplotlib using pyinstall (ver 1.3)? I am getting a: RuntimeError: Could not find the matplotlib data files when...
0
by: PamMish1982 | last post by:
Hi all, I have recently started using Python and I am trying to make a GUI out of Tkinter. I am using matplotlib for the graphic purposes. I have to make a exe file from this code. I use py2exe...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.