473,405 Members | 2,171 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,405 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 4968
>>>>> "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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.