SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(3)
2
(21)
3
(16)
4
(4)
5
(7)
6
(1)
7
(2)
8
(12)
9
(23)
10
(6)
11
(2)
12
(1)
13
(1)
14
(4)
15
(14)
16
(7)
17
(15)
18
(12)
19
(5)
20
21
(1)
22
(7)
23
(7)
24
(6)
25
(5)
26
(9)
27
(6)
28
(4)
29
(4)
30
(27)



Showing 21 results of 21

From: Joost v. E. <joo...@gm...> - 2005年11月02日 21:03:27
On Tue, 2005年11月01日 at 22:01 -0600, John Hunter wrote:
> >>>>> "Joost" == Joost van Evert <joo...@gm...> writes:
> 
> Joost> Dear list, does anyone know an easy way to zoom a part of a
> Joost> canvas and put it in a new axes, like is done in the demo
> Joost> of axes?
> Joost> http://matplotlib.sourceforge.net/screenshots/axes_demo_small.png
> 
> 
> No easy way... One could hack it out by transfering ax.lines,
> ax.patches, etc from the src to the dest and then using the zoom rect
> to define the new xlim/ylim, but there is nothing built in.
> 
> JDH
Thanks John,
just for your and the list's information: it could be done rather easy
in my case. I just want to zoom to a small part of the x axis: find the
right data and plot it on the new axes. This way it is not a matplotlib
problem, but mine;)
Regards,
Joost
-- 
Joost van Evert
Information and Communication Theory Group (ICT)
Department of Mediamatica (MM)
Faculty of Electrical Engineering, Mathematics and Computer Science
(EEMCS)
Delft University of Technology (TUD)
Mekelweg 4
Office: HB11.110
2628 CD Delft, 
the Netherlands
Phone: +31 (0) 15 - 27 85436
Mobile: +31 (0) 6 - 41 11 56 84
Email: j.g...@ew...
Url: http://ict.ewi.tudelft.nl/~joost
From: Tim G. <tg...@pr...> - 2005年11月02日 20:51:47
A couple weeks ago there was a thread on Postscript output problems on OS X=
=2E The solution was to use tex for labelling. I'd rather avoid this.
I've been running matplotlib on a Mac running 10.3 for quite some time now =
and everything has been smooth. I'm running 10.4 on my laptop and would li=
ke to get matplotlib working correctly on it, but it just doesn't seem to c=
ooperate. The two issues are the above mentioned Postscript output problem=
 (png and svg are fine) and one other error that always pops up. Whenever =
I do a plot, the first time I click on the plot, I get the following error:
 2005年11月02日 15:04:23.391 Python[22602] CFLog (21): Error loading /Users/tgr=
ay/Library/QuickTime/LiveType.component/Contents/MacOS/LiveType: error cod=
e 4, error number 0 (Library not loaded: /System/Library/PrivateFrameworks/=
LiveType.framework/Versions/A/LiveType
 Referenced from: /Users/tgray/Library/QuickTime/LiveType.component/Conten=
ts/MacOS/LiveType
 Reason: image not found)
 =20
Any ideas on either of these two problems?
From: Chris F. <fon...@gm...> - 2005年11月02日 19:29:35
I managed to compile matplotlib only with scipy (scipy_core), however,
when I try to import pylab, I get an import error as numerix strangely
tries to import numarray (even though it is not on my system). Is this
a bug? If so, what is the best workaround?
In [1]: from pylab import *
---------------------------------------------------------------------------
exceptions.ImportError Traceback (most
recent call last)
/Users/chris/<console>
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/pylab.py
----> 1 from matplotlib.pylab import *
 global matplotlib.pylab =3D undefined
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/pylab.py
 192 """
 193 import sys, warnings
--> 194 import cm
 cm =3D undefined
 195 import _pylab_helpers
 196 import mlab #so I can override hist, psd, etc...
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/cm.py
 3 """
 4
----> 5 import colors
 colors =3D undefined
 6 from matplotlib import verbose
 7 from matplotlib import rcParams
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/colors.py
 31 import re
 32
---> 33 from numerix import array, arange, take, put, Float, Int, where, \
 global numerix =3D undefined
 array =3D undefined
 arange =3D undefined
 take =3D undefined
 put =3D undefined
 Float =3D undefined
 Int =3D undefined
 where =3D undefined
 zeros =3D undefined
 asarray =3D undefined
 sort =3D undefined
 searchsorted =3D undefined
 sometrue =3D undefined
 ravel =3D undefined
 divide =3D undefined
 clip =3D undefined
 34 zeros, asarray, sort, searchsorted, sometrue, ravel, divide,\
 35 clip
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/numerix/__init__.py
 46 if which[0] =3D=3D "numarray":
 47 #from na_imports import *
---> 48 from numarray import *
 numarray =3D undefined
 49 from _na_imports import nx, inf, infinity, Infinity, Matrix
 50 from numarray.numeric import nonzero
ImportError: No module named numarray
--
Chris Fonnesbeck
Atlanta, GA
From: Eric F. <ef...@ha...> - 2005年11月02日 17:11:53
Have you tried pcolor?
Eric
>>Is there a function doing same behaviour as imshow but with 3
>>numarray.arrays:
>>- 1 for the x values.
>>- 1 for the y values.
>>- 1 for the value coloration of the point.
From: Paul B. <peb...@gm...> - 2005年11月02日 13:50:27
Hi Alexander,
I can't duplicate your problem using the patch. It works fine for me.
However, I'm using numarray and not numeric.
You might want to print out the types of the arrays on the left and right
sides and use an astype() method to convert the right side to the type of
the left side.
-- Paul
On 11/1/05, Alexander Mont <ale...@co...> wrote:
>
> I noticed that the pcolor function uses about twice as much memory as it
> needs to. When creating the list of vertices, you first create the lists =
X1,
> Y1, X2, Y2, X3, Y3, X4, and Y4, and then combine those lists into the
> "verts" list. I tried to change it to make it not waste memory by changin=
g
> the lines between the line:
> mask =3D ma.getmaskarray(C)[0:Nx-1,0:Ny-1]+xymask
> and
> C =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(C[0:Nx-1,0:Ny-1])))
> to the following:
>
> numVertices =3D len(compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,0:=
-1]))))
>
> verts =3D zeros((numVertices, 4, 2))
>
> verts[:, 0, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,0:-=
1])))
>
> verts[:, 0, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[0:-1,0:-=
1])))
>
> verts[:, 1, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[1:,0:-1]=
)))
>
> verts[:, 1, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[1:,0:-1]=
)))
>
> verts[:, 2, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[1:,1:]))=
)
>
> verts[:, 2, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[1:,1:]))=
)
>
> verts[:, 3, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,1:]=
)))
>
> verts[:, 3, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[0:-1,1:]=
)))
>
> However it says that the "array cannot be safely cast to required type"
> on the third line (verts[:, 0, 0] =3D ...). I have no idea why this is
> happening because both arrays are the same length (numVertices). Does any=
one
> have any ideas how to fix this problem?
>
> Also, if I do get this working, is there a way to submit it as a patch?
> Having a pcolor function that doesn't use up so much memory might be usef=
ul
> for lot of people, not just me.
>
> -Alex Mont
>
From: Chris F. <fon...@gm...> - 2005年11月02日 13:39:01
Is it possible to build matpoltlib with scipy_core support, rather
than Numeric or numarray? I did what I thought was a successful build
and install, but a quick test resulted in some Tkinter backend errors:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/pylab.py
in plot(*args=3D(array([3, 4, 5, 6]), array([ 9, 16, 25, 36])),
**kwargs=3D{})
 2020 def plot(*args, **kwargs):
 2021 # allow callers to override the hold state by passing
hold=3DTrue|False
-> 2022 b =3D ishold()
 b =3D undefined
 global ishold =3D <function ishold at 0x3061c30>
 2023 h =3D popd(kwargs, 'hold', None)
 2024 if h is not None:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/pylab.py
in ishold()
 896 Return the hold status of the current axes
 897 """
--> 898 return gca().ishold()
 global gca.ishold =3D undefined
 899
 900 def isinteractive():
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/pylab.py
in gca(**kwargs=3D{})
 847 """
 848
--> 849 ax =3D gcf().gca(**kwargs)
 ax =3D undefined
 global gcf.gca =3D undefined
 kwargs =3D {}
 850 return ax
 851
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/pylab.py
in gcf()
 857 return figManager.canvas.figure
 858 else:
--> 859 return figure()
 global figure =3D <function figure at 0x3061af0>
 860
 861 def gci():
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/pylab.py
in figure(num=3D1, figsize=3D[8.0, 6.0], dpi=3D80.0, facecolor=3D0.75,
edgecolor=3D'white', frameon=3DTrue)
 827 figManager.canvas.figure.number =3D num
 828
--> 829 draw_if_interactive()
 global draw_if_interactive =3D <function wrapper at 0x314d730>
 830 return figManager.canvas.figure
 831
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/IPython/genutils.py
in wrapper(*args=3D(), **kw=3D{})
 683 def wrapper(*args,**kw):
 684 wrapper.called =3D False
--> 685 out =3D func(*args,**kw)
 out =3D undefined
 global func =3D undefined
 args =3D ()
 kw =3D {}
 686 wrapper.called =3D True
 687 return out
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/backends/backend_tkagg.py
in draw_if_interactive()
 57 figManager =3D Gcf.get_active()
 58 if figManager is not None:
---> 59 figManager.show()
 figManager.show =3D <bound method FigureManagerTkAgg.show of
<matplotlib.backends.backend_tkagg.FigureManagerTkAgg instance at
0x3066e68>>
 60
 61
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/backends/backend_tkagg.py
in show(self=3D<matplotlib.backends.backend_tkagg.FigureManagerTkAgg
instance at 0x3066e68>)
 295 if sys.platform=3D=3D'win32' : self.window.update()
 296 else:
--> 297 self.canvas.draw()
 self.canvas.draw =3D <bound method FigureCanvasTkAgg.draw of
<matplotlib.backends.backend_tkagg.FigureCanvasTkAgg instance at
0x30667d8>>
 298 self._shown =3D True
 299
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/backends/backend_tkagg.py
in draw(self=3D<matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
instance at 0x30667d8>)
 150 def draw(self):
 151 FigureCanvasAgg.draw(self)
--> 152 tkagg.blit(self._tkphoto, self.renderer._renderer, 2)
 global tkagg.blit =3D <function blit at 0x44df30>
 self._tkphoto =3D <Tkinter.PhotoImage instance at 0x30668f0>
 self.renderer._renderer =3D <RendererAgg object at 0x6223224>
 153 self._master.update_idletasks()
 154
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag=
es/matplotlib/backends/tkagg.py
in blit(photoimage=3D<Tkinter.PhotoImage instance at 0x30668f0>,
aggimage=3D<RendererAgg object at 0x6223224>, colormode=3D2)
 12 except AttributeError:
 13 _tkagg.tkinit(id(tk), 0)
---> 14 tk.call("PyAggImagePhoto", photoimage,
id(aggimage), colormode)
 tk.call =3D <built-in method call of tkapp object at 0x30586e8>
 photoimage =3D <Tkinter.PhotoImage instance at 0x30668f0>
 global id =3D undefined
 aggimage =3D <RendererAgg object at 0x6223224>
 colormode =3D 2
 15 except (ImportError, AttributeError, Tk.TclError):
 16 raise
TclError: usage: PyAggImagePhoto destPhoto srcImage
In [5]: Exception in Tkinter callback
Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib=
-tk/Tkinter.py",
line 1345, in __call__
 return self.func(*args)
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sit=
e-packages/matplotlib/backends/backend_tkagg.py",
line 148, in resize
 self.show()
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sit=
e-packages/matplotlib/backends/backend_tkagg.py",
line 152, in draw
 tkagg.blit(self._tkphoto, self.renderer._renderer, 2)
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sit=
e-packages/matplotlib/backends/tkagg.py",
line 14, in blit
 tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode)
TclError: usage: PyAggImagePhoto destPhoto srcImage
--
Chris Fonnesbeck
Atlanta, GA
From: John N. <j5n...@ya...> - 2005年11月02日 13:11:05
Hi,
I'm using darwinports to install matplotlib with the
tkagg backend on a Mac OS X Tiger 10.4.2.
I've come across a problem in that when I run the
simple_plot.py script (see below) from the matplotlib
screeenshots page, I get the following error:
"ImportError: No module named _tkagg". (for detailed
output see below).
Does any one have any insight? 
Thanks, John
===Details===
I'm running the script as:
$python2.4 simple_plot.py
I've edited my .matplotlibrc to use the TkAgg backend.
I've tested python's ability to import Tkinter by:
>>>import Tkinter
>>>Tkinter._test(). 
I observe a small Click me window when I
runTkinter._test()
I've used darwinports to install:
 antigraingeometry 2.3_5 (active)
 freetype 2.1.9_1 (active)
 libpng 1.2.8_2+darwin_8 (active)
 py-dateutil 0.5_1 (active)
 py-matplotlib 0.82_0 (active)
 py-numarray 1.4.1_0+darwin_8 (active)
 py-numeric 24.0_0+darwin_8 (active)
 py-tkinter 2.4.1_0 (active)
 py-tz 2004d_1 (active)
 python24 2.4.1_6 (active)
 tcl 8.4.11_2 (active)
 tk 8.4.11_3 (active)
 zlib 1.2.3_0 (active)
Here is detailed the error message:
==============
Traceback (most recent call last):
 File "TestPlot.py", line 8, in ?
 from pylab import *
 File
"/opt/local/lib/python2.4/site-packages/pylab.py",
line 1, in ?
 from matplotlib.pylab import *
 File
"/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py",
line 199, in ?
 import backends
 File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 19, in ?
 globals(),locals(),[backend_name])
 File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 8, in ?
 import tkagg # Paint image to Tk
photo blitter extension
 File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/tkagg.py",
line 1, in ?
 import _tkagg
ImportError: No module named _tkagg
==================
And finally here's simple_plot.py:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
show()
		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
From: Jiri P. <po...@ph...> - 2005年11月02日 10:34:22
 Good day,
is possible to use Times-Roman font in my plots? I try to use
 rc('font', family='times-roman')
but it is not working.
--
JP
From: Christian K. <ck...@ho...> - 2005年11月02日 09:49:43
Sorry, I send an empty reply.
Philou wrote:
> Hi list,
> 
> Is there a function doing same behaviour as imshow but with 3
> numarray.arrays:
> - 1 for the x values.
> - 1 for the y values.
> - 1 for the value coloration of the point.
> 
> For imshow, we only need the array bidimensionnal containing value of
> the coloration and the coordinates of the point are determine by the
> position of the coloration value on the first and on the second dimension.
If both x- and y-data are equidistant then you can use the 'extent' keyword
parameter to specify the x- and y-axis range of the image by hand. If not, you
could try the contourf function.
Christian
From: Christian K. <ck...@ho...> - 2005年11月02日 09:44:05
Philou wrote:
> Hi list,
> 
> Is there a function doing same behaviour as imshow but with 3
> numarray.arrays:
> - 1 for the x values.
> - 1 for the y values.
> - 1 for the value coloration of the point.
> 
> For imshow, we only need the array bidimensionnal containing value of
> the coloration and the coordinates of the point are determine by the
> position of the coloration value on the first and on the second dimension.
> 
> Thanks a lot,
> Philippe Collet
> 
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Philou <Kal...@wa...> - 2005年11月02日 09:41:44
Hi list,
Is there a function doing same behaviour as imshow but with 3 
numarray.arrays:
- 1 for the x values.
- 1 for the y values.
- 1 for the value coloration of the point.
For imshow, we only need the array bidimensionnal containing value of 
the coloration and the coordinates of the point are determine by the 
position of the coloration value on the first and on the second dimension.
Thanks a lot,
Philippe Collet
From: Alastair B. <a.g...@du...> - 2005年11月02日 09:32:38
<Have you looked at the animation examples that come with the
<matplotlib distribution?
<
<matplotlib/examples> ls *anim* dynamic_* sys*
<animation_blit_fltk.py anim.py dynamic_image_gtkagg.py
<animation_blit.py anim_tk.py dynamic_image_wxagg2.py
<animation_blit_tk.py dynamic_demo.py dynamic_image_wxagg.py
<animation_blit_wx.py dynamic_demo_wx.py system_monitor.py
<
Thanks... should have though of checking for an examples directory. The 
dynamic_image_gtkagg.py is an example of what I want. However, it seems 
to be a bit flickery - is there any way of double buffering or similar so 
that the flicker won't be obvious?
Thanks.
From: John H. <jdh...@ac...> - 2005年11月02日 04:18:18
>>>>> "Alastair" == Alastair Basden <a.g...@du...> writes:
 Alastair> Hi, I've recently started using pylab, and its not clear
 Alastair> to me how to do a 2d animation.
 Alastair> If I have a 3d numeric array (eg
 Alastair> arr=RandomArray.randint(0,127,(100,256,256))) how can I
 Alastair> display arr[0], then arr[1], then...
 Alastair> The way I've tried seems to slow down as I progress,
 Alastair> suggesting that its drawing all previous arrays before
 Alastair> drawing the current one.
Have you looked at the animation examples that come with the
matplotlib distribution?
matplotlib/examples> ls *anim* dynamic_* sys*
animation_blit_fltk.py anim.py dynamic_image_gtkagg.py
animation_blit.py anim_tk.py dynamic_image_wxagg2.py
animation_blit_tk.py dynamic_demo.py dynamic_image_wxagg.py
animation_blit_wx.py dynamic_demo_wx.py system_monitor.py
From: John H. <jdh...@ac...> - 2005年11月02日 04:15:28
>>>>> "Rick" == Rick Muller <rm...@sa...> writes:
 Rick> I'm finding some really weird behavior in matplotlib that I
 Rick> just can't figure out.
 Rick> When I plot out the following short script:
 >>>> from pylab import * y =
 >>>> [-48.0694,-48.0754,-48.0772,-48.0781,-48.0782,-48.0781,
 Rick> -48.0772,-48.0720]
 >>>> plot(y) savefig('bs.png')
 Rick> I get a y-axis that goes from -10 to 0, instead of -48.0782
 Rick> - -48.0694. And in the upper left hand corner of the plot I
 Rick> see the string "x1e-3-4.8069e1".
This is mostly a feature and not a bug :-). See
examples/newscalarformatter_demo.py for the range of pathalogical
cases the exponential formatting with offsets was designed to solve.
But it can be annoying as I've discovered in some recent plots..
Darren, I think the new scalar formatter kicks in too early some
times, and it might be nice to be able to control this, eg with an rc
setting. Ie, one might want to say for certain scripts, fall over to
exponential / offset formatting for decades on the order of 1e4 or 1e6
or 1e10. Would it be easy to add such a configuration parameter to
the ScalarFormatter?
Rick; note that you can override the default tick formatter (see the
matplotlib.ticker class docs at
http://matplotlib.sf.net/matplotlib.ticker.html and the relevant
chapter of the users guide and the major_minor_*.py demos in the
examples subdirectory) but one wants it to "just work" (TM) more
often....
JDH
From: John H. <jdh...@ac...> - 2005年11月02日 04:05:23
>>>>> "Joost" == Joost van Evert <joo...@gm...> writes:
 Joost> Dear list, does anyone know an easy way to zoom a part of a
 Joost> canvas and put it in a new axes, like is done in the demo
 Joost> of axes?
 Joost> http://matplotlib.sourceforge.net/screenshots/axes_demo_small.png
No easy way... One could hack it out by transfering ax.lines,
ax.patches, etc from the src to the dest and then using the zoom rect
to define the new xlim/ylim, but there is nothing built in.
JDH
From: John H. <jdh...@ac...> - 2005年11月02日 04:04:13
>>>>> "Bill" == Bill Dandreta <wjd...@at...> writes:
 Bill> Using matplotlib 0.84, python 2.4, scipy 0.3.2, numeric
 Bill> 23.7. date_demo3.py does not work as is.
 Bill> Below is a 'diff' file that will create a date_demo3.py that
 Bill> does what I think the original intended to do.
Strange, I am not aware of a date_demo3.py
 matplotlib/examples> ls date*.py
 date_demo1.py date_demo2.py date_demo_convert.py date_demo_rrule.py
What am I missing (aside from date_demo3.py <wink>)?
JDH
From: John H. <jdh...@ac...> - 2005年11月02日 04:01:34
>>>>> "Bill" == Bill Dandreta <wjd...@at...> writes:
 Bill> Using matplotlib 0.84, python 2.4, scipy 0.3.2, numeric 23.7
 Bill> I get errors when running date_demo_rrule.py.
What errors? The set/sep error alluded to below? This is actually
fixed in 0.84 and CVS. Unfortunately, the web site may not have been
updated. Grap the 0.84 zip or tar.gz file for the latest examples
dir, and I'll try and get the web site updated soonish.
 Bill> Since the demo scripts are for educational purposes and
 Bill> primarily used by newbies, I have a couple of suggestions.
 Bill> 1. Don't use import *
 Bill> 2. Don't import functions from submodules, instead use the
 Bill> submodule name when calling the function. It makes it much
 Bill> clearer to see where the function came from.
Reasonable suggestions all, and ones that have been brought up many
times before. I believe there is a balance between teaching and
convenience. For many new students, they just want the functions to
*be there* eg, rand, fft, psd, and don't want to sort out where they
come from. This is doubly or triply true considering the namespace
issues of Numeric, numarray, and scipy (quick, where does rand live in
numarray, scipy, Numeric, matplotlib and old scipy?). But I also
agree that it is healthy to force people to think about these issues
and learn the origins of these packages. So my rule of thumb is to
use namespaces when writing new examples, and to accept patches for
old ones. If you could resubmit your patch against matplotlib CVS I
would be happy to make the changes.
Thanks,
JDH
From: John H. <jdh...@ac...> - 2005年11月02日 03:45:52
>>>>> "Alexander" == Alexander Mont <ale...@co...> writes:
 Alexander> Thanks for your advice with installing matplotlib on
 Alexander> cygwin. I downloaded and installed the windows binaries
 Alexander> and it worked. Anyway, the reason that I didn't want
 Alexander> to use binaries in the first place was because I wanted
 Alexander> to modify the matplotilb source code. But it seems like
 Alexander> even with the binaries, if I change the source code
 Alexander> then it will still affect the operation of the program
 Alexander> when I run it, which is what I want.
 Alexander> In particular, I am looking to speed up the pcolor()
 Alexander> function because it runs exceedingly slow with large
 Alexander> mesh sizes. I believe the reason it is running slow is
 Alexander> because of a memory leak. When I do the following:
 Alexander> from pylab import * n=200
 Alexander> [x,y]=meshgrid(arange(n+1)*1./n,arange(n+1)*1./n)
 Alexander> z=sin(x**2 + y**2)
 Alexander> and then do
 Alexander> pcolor(x,y,z)
 Alexander> repeatedly, the memory usage increases by about 15 MB
 Alexander> each time, and it runs progressively slower.each
At least with matplotlib CVS (and I don't think it's a CVS vs 0.84
issue) the memory consumption is rock solid with your example (see
below for my test script). What is your default "hold" setting in rc?
If True, you will be overlaying plots and will get the behavior you
describe. In the example below, I make sure to "close" the figure
each time -- a plain clear with clf should suffice though. My guess
is that you are repeatedly calling pcolor with hold : True and are
simply overlaying umpteen pcolors (to test for this, print the length
of the collections list
 ax = gca()
 print len(ax.collections)
if this length is growing, you've found your problem. A simple
 pcolor(x,y,z,hold=False)
should suffice.
You can also change the default hold setting in your config file
http://matplotlib.sf.net/matplotlibrc
JDH
Example code:
#!/usr/bin/env python
import os, sys, time
import matplotlib
#matplotlib.interactive(True)
#matplotlib.use('Cairo')
matplotlib.use('Agg')
from pylab import *
def report_memory(i):
 pid = os.getpid()
 a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
 print i, ' ', a2[1],
 return int(a2[1].split()[1])
# take a memory snapshot on indStart and compare it with indEnd
indStart, indEnd = 30, 201
for i in range(indEnd):
 figure(1); clf()
 n=200
 [x,y]=meshgrid(arange(n+1)*1./n,arange(n+1)*1./n)
 z=sin(x**2 + y**2)
 pcolor(x,y,z)
 savefig('tmp%d' % i, dpi = 75)
 close(1)
 val = report_memory(i)
 if i==indStart: start = val # wait a few cycles for memory usage to stabilize
end = val
print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
"""
Average memory consumed per loop: 0.0053k bytes
"""
From: Alexander M. <ale...@co...> - 2005年11月02日 03:45:07
I noticed that the pcolor function uses about twice as much memory as it =
needs to. When creating the list of vertices, you first create the lists =
X1, Y1, X2, Y2, X3, Y3, X4, and Y4, and then combine those lists into =
the "verts" list. I tried to change it to make it not waste memory by =
changing the lines between the line:
mask =3D ma.getmaskarray(C)[0:Nx-1,0:Ny-1]+xymask
and
C =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(C[0:Nx-1,0:Ny-1])))
to the following:
numVertices =3D =
len(compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,0:-1]))))
verts =3D zeros((numVertices, 4, 2))
verts[:, 0, 0] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,0:-1])))
verts[:, 0, 1] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[0:-1,0:-1])))
verts[:, 1, 0] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(X[1:,0:-1])))
verts[:, 1, 1] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[1:,0:-1])))
verts[:, 2, 0] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(X[1:,1:])))
verts[:, 2, 1] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[1:,1:])))
verts[:, 3, 0] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,1:])))
verts[:, 3, 1] =3D =
compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[0:-1,1:])))
However it says that the "array cannot be safely cast to required type" =
on the third line (verts[:, 0, 0] =3D ...). I have no idea why this is =
happening because both arrays are the same length (numVertices). Does =
anyone have any ideas how to fix this problem?
Also, if I do get this working, is there a way to submit it as a patch? =
Having a pcolor function that doesn't use up so much memory might be =
useful for lot of people, not just me.
-Alex Mont
From: John H. <jdh...@ac...> - 2005年11月02日 03:35:39
>>>>> "Clovis" == Clovis Goldemberg <cl...@pe...> writes:
 Clovis> The question is: "why isn't the memory collected after
 Clovis> closing the figure?". The real program I developed builds
 Clovis> 5~15 graphic windows and the required memory is very
 Clovis> large.
It is, or it should be. Look at the module _pylab_helpers,
particularly this function which is called when a window is destroyed
 def destroy(num):
 if not Gcf.has_fignum(num): return
 figManager = Gcf.figs[num]
 oldQue = Gcf._activeQue[:]
 Gcf._activeQue = []
 for f in oldQue:
 if f != figManager: Gcf._activeQue.append(f)
 del Gcf.figs[num]
 #print len(Gcf.figs.keys()), len(Gcf._activeQue)
 figManager.destroy()
 gc.collect()
ie, we make an explicit call to the garbage collector when a figure is
destroyed from within pylab. I'm not sure why you are not seeing the
memory freed up, but I believe garbage collection is a bit of a
mystery about what happens where.
I tend to rely on a script called unit/memleak_hawaii3.py which is in
matplotlib CVS to test for memory leaks. Unfortunately this works
only on linux and friends because it uses ps to collect memory usage.
Typically we like to see total memory asymptote out at around 10 to 30
figures and cease climbing. If it climbs monotonically with figure
number, it's indicative of a leak. For reasons beyond me, the memory
consumption doesn't stabilize for the first N figures, where N is an
arbitrary but smallish number. I don't think this has to do with
matplotlib as much as with the python garbage collector.
If you get a chance to test this script on linux, I would be
interested to hear what you find. If someone else knows more about
python's gc, please pipe in.
JDH
From: Bill D. <wjd...@at...> - 2005年11月02日 03:04:20
Using matplotlib 0.84, python 2.4, scipy 0.3.2, numeric 23.7.
date_demo3.py does not work as is.
Below is a 'diff' file that will create a date_demo3.py that does what I 
think the original intended to do.
------------------------
wjd@plum ~/test $ diff date_demo3.py ../matplotlib_examples/date_demo3.py
8c8
< import datetime
---
 > from datetime import datetime
10c10,12
< from pylab import 
date2num,array,rand,subplot,HourLocator,MinuteLocator,DateFormatter,bar,show
---
 > from matplotlib.dates import intdate
 > from matplotlib.ticker import MinuteLocator, DateFormatter
 > from matplotlib.matlab import *
13,14c15,16
< t0 = datetime.datetime(2004,04,27)
< t = array([date2num(t0+datetime.timedelta(minutes=2*i)) for i in 
range(60)])
---
 > t0 = time.mktime(datetime(2004,04,27).timetuple())
 > t = t0+arange(0, 2*3600, 60) # 2 hours sampled every 2 minute
18c20
< ax.xaxis.set_major_locator( MinuteLocator(byminute=range(0,60,20) ))
---
 > ax.xaxis.set_major_locator( MinuteLocator(20) )
20,21c22
< #1 bar every 2 minutes, bar width = space between bars, 1440 minutes 
per day
< bar(t, s, width=1.0/1440)
---
 > bar(t, s, width=60)
22a24,26
-----------------------------------
Bill

Showing 21 results of 21

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 によって変換されたページ (->オリジナル) /