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
(22)
2
(17)
3
(21)
4
(7)
5
(7)
6
(17)
7
(8)
8
(8)
9
(33)
10
(11)
11
12
(2)
13
(11)
14
(29)
15
(13)
16
(13)
17
(3)
18
(2)
19
(3)
20
(7)
21
(17)
22
(12)
23
(19)
24
(19)
25
(14)
26
(5)
27
(25)
28
(13)




Showing 21 results of 21

From: Samuel M. S. <sm...@sa...> - 2006年02月01日 23:02:56
I had installed numarray 1.1.1 and Numeric 23.7 using package 
installers from http://pythonmac.org/packages/
I downloaded numarray 1.5 tarball and unpacked it. I used the 
following command pointing to the include directory
in the 1.5 distribution.
> CPPFLAGS="-I/foo/bar/" sudo python setup.py build
 My previous error went away but I go another similar error for 
Numeric.
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused- 
madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes - 
I/install/python/macpython/python2.4.2/numerical/numarray-1.5.0/ 
include -Isrc -I. -I/usr/local/include -I/usr/include -I. -I/System/ 
Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 -c 
src/_nc_transforms.cpp -o build/temp.darwin-8.4.0-Power_Macintosh-2.3/ 
src/_nc_transforms.o -DNUMERIC=1
src/_nc_transforms.cpp:10:40: Numeric/arrayobject.h: No such file or 
directory
so I download Numeric 24.2 and decided to go ahead and install it. 
Which was successful
While I was at it I decided to install numarray 1.5 which installed 
without complaining but when I tried to import it to test
I get the following error
 >>> import numarray
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/numarray/__init__.py", line 42, in ?
 from numarrayall import *
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/numarray/numarrayall.py", line 2, in ?
 from generic import *
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/numarray/generic.py", line 1036, in ?
 import numarraycore as _nc
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/numarray/numarraycore.py", line 1472, in ?
 import ufunc
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/numarray/ufunc.py", line 1658, in ?
 _choose = _ChooseUFunc()
TypeError: function takes exactly 5 arguments (0 given)
I then tried doing a python setup.py clean in the matplotlib 
distribution directory and the clean failed because
it also tries to import numarray.
So I guess now I have to fix numarray. Any Ideas what is broken?
Christopher Barker wrote:
> I guess it may be time for me to join matplotlib-devel.
Chris,
I should have copied the message to you and/or left it on 
matplotlib-users instead of switching it to devel--but I thought I would 
try to keep down the traffic on users. My mistake, in this case; I'm 
sorry. But yes, there are advantages in joining devel, too, so I 
encourage it.
> 
> Eric Firing wrote:
> 
>> Eric> If this strategy sounds reasonable to you,
> 
> 
> What was that strategy?
The remainder of this message is what I sent to John and mpl-devel:
Chris Barker found a problem: plotting in an axes, then calling 
axes.cla, then adding a collection, then calling axes.plot, results in 
the original plot's dataLim being used as the starting point for the 
update. I think the problems are:
1) axes.add_line updates the data limits, but add_collection does not;
2) axes.has_data is simply looking to see whether a line or collection 
has been added, but is using that as an indication of whether the data 
limits have been set; this is invalid because add_collection does not 
set the limits.
I suggest two changes to address the problem:
1) Use a flag instead of the have_data() method to keep track of whether 
data limit updating needs to start from scratch. Then axes.cla() can 
set the flag, and the update_datalim* functions can clear it.
2) Add an optional flag to add_collection, telling it to call the 
collection's get_verts method and use the result to update the data 
limits. This would make it easier to use collections in user-level 
code, without imposing any performance penalty for functions like 
contour that handle the data limit updating in a more efficient way.
If this strategy sounds reasonable to you, I can go ahead and implement it.
Eric
From: Darren D. <dd...@co...> - 2006年02月01日 22:20:22
I made some improvements to the usetex option over the last few days in order 
to make font selection fit seemlessly with the rest of Matplotlib. The usetex 
option will now respect the serif, sans-serif, monospace, and cursive rc 
settings. Usetex looks until it finds a latex-compatible font, or defaults to 
computer modern. Proper font support with plainTeX is more difficult, and 
everyone seems to use the latex backend anyway, so I am dropping support of 
the tex engine. With these changes, the font.latex.package and the 
text.tex.engine rc settings are no longer needed, and should be removed from 
ones personal matplotlibrc file.
Here are the currently supported latex fonts:
- serif: Times, Palatino, Bookman, New Century Schoolbook, Charter, Computer 
Modern Roman (Times and Palatino have their own math fonts, the others 
default to computer modern math fonts)
- sans-serif: Helvetica, Avant Garde, Computer Modern Sans Serif (I added 
Avant Garde to the matplotlibrc.template)
- monospace: Courier, Computer Modern Typewriter
- cursive: Zapf Chancery
The font.family setting is respected and should be used to switch from one 
family to another. Cursive fonts are supported with latex, but fantasy fonts 
are not (raises a warning and defaults to serif). If you use the usetex 
option, please kick the tires and let me know how it goes.
Darren
From: Christopher B. <Chr...@no...> - 2006年02月01日 22:12:18
I guess it may be time for me to join matplotlib-devel.
Eric Firing wrote:
> Eric> If this strategy sounds reasonable to you,
What was that strategy?
> From: John Hunter <jdh...@ac...>
> Just a comment for now. If you look at ax.add_collection, it does not
> update the datalim. This is by design but it should be documented.
I suspected as much. Could we add an optional flag, so that the user 
could ask that the datalim to be updated?
> minx, maxx = (0, len(rangeSegments))
> miny = min([low for low in lows if low !=-1])
> maxy = max([high for high in highs if high != -1])
> 
> corners = (minx, miny), (maxx, maxy)
> ax.update_datalim(corners)
> ax.autoscale_view()
I had figured I might need to do that, but it seems a shame to have to 
have a bunch of people writing that code all over the place.
Another option might be to make code like this a method of the 
LineCollection class, and then you could do:
ax.add_collection(MyLineCollection)
ax.update_datalim(MyLineCollection.CalcLimits())
A question, though. The segments are in different data units, rather 
that axes units. In fact they are then shifter by the "offsets", so the 
above code wouldn't do it. That might be a good argument for making this 
calculation be a method of the LineCollection class. That method could 
be overridden, as appropriate, for a subclass. Then the 
axes.add_collection code could call that method to update the datalim. 
For performance purposes, you could make it no-op by default.
One more thought:
I suspect that in many cases a LineCollection will hold a set of 
segments that are all the same size. In my example, every segment is 5 
points long, so I could store it in a NX5X2 array, and make the above 
calculation much faster.
> As for how the datalim handling works, the syntax is
Thanks for the overview.
My last question:
Is there a reason that axes.cla() doesn't reset datalim?
thanks,
-Chris
From: Charlie M. <cw...@gm...> - 2006年02月01日 21:27:07
 The numarray headers are installed along with numarray. Try
locating the file "numarray/arrayobject.h" on your computer. MPL is
finding the numarray module, so they must be around somewhere.
 Say you find it in "/foo/bar/numarray/arrayobject.h". Try
running this command:
CPPFLAGS=3D"-I/foo/bar/" sudo python setup.py build
If you can't find the file, then tell us how you installed numarray.
- Charlie
On 2/1/06, Samuel M. Smith <sm...@sa...> wrote:
> I am trying to build 0.86.2 on OS X 10.4.4 with framework build of
> python 2.4.2
> I have default gcc set to 3.3
>
> when I run sudo python setup.py build I get the following error
>
> gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
> madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -
> Isrc -I. -I/usr/local/include -I/usr/include -I. -I/System/Library/
> Frameworks/Python.framework/Versions/2.3/include/python2.3 -c src/
> _na_transforms.cpp -o build/temp.darwin-8.4.0-Power_Macintosh-2.3/src/
> _na_transforms.o -DNUMARRAY=3D1
> src/_na_transforms.cpp:7:37: numarray/arrayobject.h: No such file or
> directory
> src/_na_transforms.cpp: In member function `Py::Object
> Bbox::update_numerix(const Py::Tuple&)':
> src/_na_transforms.cpp:455: error: `PyArrayObject' undeclared (first
> use this
> function)
> src/_na_transforms.cpp:455: error: (Each undeclared identifier is
> reported only
> once for each function it appears in.)
> src/_na_transforms.cpp:455: error: `x' undeclared (first use this
> function)
> src/_na_transforms.cpp:455: error: parse error before `)' token
> src/_na_transforms.cpp:461: error: `y' undeclared (first use this
> function)
> src/_na_transforms.cpp:461: error: parse error before `)' token
> src/_na_transforms.cpp: In member function `Py::Object
> Transformation::numerix_x_y(const Py::Tuple&, const Py::Dict&)':
> src/_na_transforms.cpp:848: error: parse error before `)' token
> src/_na_transforms.cpp:854: error: parse error before `)' token
> src/_na_transforms.cpp:879: error: `retx' undeclared (first use this
> function)
> src/_na_transforms.cpp:879: error: parse error before `)' token
> src/_na_transforms.cpp:886: error: `rety' undeclared (first use this
> function)
> src/_na_transforms.cpp:886: error: parse error before `)' token
> src/_na_transforms.cpp: In member function `Py::Object
> Transformation::nonlinear_only_numerix(const Py::Tuple&, const
> Py::Dict&)':
> src/_na_transforms.cpp:933: error: parse error before `)' token
> src/_na_transforms.cpp:939: error: parse error before `)' token
> src/_na_transforms.cpp:955: error: parse error before `)' token
> src/_na_transforms.cpp:962: error: parse error before `)' token
> src/_na_transforms.cpp:970: error: `retmask' undeclared (first use this
> function)
> src/_na_transforms.cpp:973: error: parse error before `)' token
> src/_na_transforms.cpp: In function `void init_na_transforms()':
> src/_na_transforms.cpp:2068: error: `import_array' undeclared (first
> use this
> function)
> error: command 'gcc' failed with exit status 1
>
> It looks like its expecting there to be a source distribution of
> numarray some place
>
> Anyone know what I need to do to fix this?
>
>
>
From: Samuel M. S. <sm...@sa...> - 2006年02月01日 21:14:23
I am trying to build 0.86.2 on OS X 10.4.4 with framework build of 
python 2.4.2
I have default gcc set to 3.3
when I run sudo python setup.py build I get the following error
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused- 
madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes - 
Isrc -I. -I/usr/local/include -I/usr/include -I. -I/System/Library/ 
Frameworks/Python.framework/Versions/2.3/include/python2.3 -c src/ 
_na_transforms.cpp -o build/temp.darwin-8.4.0-Power_Macintosh-2.3/src/ 
_na_transforms.o -DNUMARRAY=1
src/_na_transforms.cpp:7:37: numarray/arrayobject.h: No such file or 
directory
src/_na_transforms.cpp: In member function `Py::Object
 Bbox::update_numerix(const Py::Tuple&)':
src/_na_transforms.cpp:455: error: `PyArrayObject' undeclared (first 
use this
 function)
src/_na_transforms.cpp:455: error: (Each undeclared identifier is 
reported only
 once for each function it appears in.)
src/_na_transforms.cpp:455: error: `x' undeclared (first use this 
function)
src/_na_transforms.cpp:455: error: parse error before `)' token
src/_na_transforms.cpp:461: error: `y' undeclared (first use this 
function)
src/_na_transforms.cpp:461: error: parse error before `)' token
src/_na_transforms.cpp: In member function `Py::Object
 Transformation::numerix_x_y(const Py::Tuple&, const Py::Dict&)':
src/_na_transforms.cpp:848: error: parse error before `)' token
src/_na_transforms.cpp:854: error: parse error before `)' token
src/_na_transforms.cpp:879: error: `retx' undeclared (first use this 
function)
src/_na_transforms.cpp:879: error: parse error before `)' token
src/_na_transforms.cpp:886: error: `rety' undeclared (first use this 
function)
src/_na_transforms.cpp:886: error: parse error before `)' token
src/_na_transforms.cpp: In member function `Py::Object
 Transformation::nonlinear_only_numerix(const Py::Tuple&, const 
Py::Dict&)':
src/_na_transforms.cpp:933: error: parse error before `)' token
src/_na_transforms.cpp:939: error: parse error before `)' token
src/_na_transforms.cpp:955: error: parse error before `)' token
src/_na_transforms.cpp:962: error: parse error before `)' token
src/_na_transforms.cpp:970: error: `retmask' undeclared (first use this
 function)
src/_na_transforms.cpp:973: error: parse error before `)' token
src/_na_transforms.cpp: In function `void init_na_transforms()':
src/_na_transforms.cpp:2068: error: `import_array' undeclared (first 
use this
 function)
error: command 'gcc' failed with exit status 1
It looks like its expecting there to be a source distribution of 
numarray some place
Anyone know what I need to do to fix this?
From: mike c. <mc...@st...> - 2006年02月01日 20:29:48
I figured it out myself
self.axes.set_title(title)
Sorry to bother you all...
mc
At 12:22 PM 2/1/2006, mike cantor wrote:
>Hi,
>
>I embed a matplotlib canvas in a wxPython dialog. This works great and 
>the title of the figure is displayed as the window title for the dialog, 
>which is dandy. Here is a stripped down version of the code (minus 
>navigation toolbar etc)
>
>class PlotDialog(wx.Dialog):
> def __init__(
> self, parent, ID, title, MakeFigArgs, size=wx.DefaultSize, 
> pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):
>
> # Precreation code
> pre = wx.PreDialog()
> pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
> pre.Create(parent, ID, title, pos, size, style)
> self.PostCreate(pre)
>
> self.canvas = FigureCanvas(self, -1, self.figure)
> self.figure = Figure(figsize=(5,4), dpi=100)
> self.axes = self.figure.add_subplot(111)
> self.axes.plot([1,2,3], [1,2,3]
>
>However, I also want the title to appear in the plot itself, so that when 
>I issue:
>
>self.canvas.Copy_to_Clipboard(event=evt).
>
>I have a title with my plot. Simply adding
>
>title("The Title")
>
>Does nothing.
>
>Any tips?
>Thanks -mike
From: mike c. <mc...@st...> - 2006年02月01日 20:22:34
Hi,
I embed a matplotlib canvas in a wxPython dialog. This works great and the 
title of the figure is displayed as the window title for the dialog, which 
is dandy. Here is a stripped down version of the code (minus navigation 
toolbar etc)
class PlotDialog(wx.Dialog):
 def __init__(
 self, parent, ID, title, MakeFigArgs, size=wx.DefaultSize, 
pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):
 # Precreation code
 pre = wx.PreDialog()
 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
 pre.Create(parent, ID, title, pos, size, style)
 self.PostCreate(pre)
 self.canvas = FigureCanvas(self, -1, self.figure)
 self.figure = Figure(figsize=(5,4), dpi=100)
 self.axes = self.figure.add_subplot(111)
 self.axes.plot([1,2,3], [1,2,3]
However, I also want the title to appear in the plot itself, so that when I 
issue:
self.canvas.Copy_to_Clipboard(event=evt).
I have a title with my plot. Simply adding
title("The Title")
Does nothing.
Any tips?
Thanks -mike
From: Eric F. <ef...@ha...> - 2006年02月01日 20:04:51
Chris,
I will forward to matplotlib-users a message from John including text 
that he had intended to send to that list and to you, and that answers 
some of your questions. I hope to have the problem fixed in cvs this 
weekend.
Eric
Christopher Barker wrote:
[.......]
> 
> I think the relevant questions are these:
> 
> Is there a reason that add_collection doesn't reset the dataLim?
> 
> Is there a reason that axes.cla() doesn't reset the dataLim?
> 
> The fix will depend on those answers. I'd like to see both done.
> 
> John?
> 
> Thanks for your help, Eric.
> 
> -Chris
> 
> 
From: Christopher B. <Chr...@no...> - 2006年02月01日 19:40:51
Eric Firing wrote:
> Attached is a slight modification of your test case, with annotations.
Thanks Eric, that does work. I'd rather the Z-order be set with the 
LineCollection under the plot, but it doesn't matter much, and I can 
probably manipulate that by hand if need be.
> think it does what you want--sort of. But I agree that there is a bug. 
> After chasing references backwards and forwards through axes.py, 
> axis.py, ticker.py, and _transforms.cpp, I don't quite understand how 
> everything works,
You got father than me.
> Workarounds: either set the dataLim explicitly, or add the collection 
> after the plot command (as in the attached modified script). The latter 
> only works if the plot command sets the dataLim to be large enough to 
> cover everything in the collection.
Yes, I may need to set dataLim myself after all.
> I would like to make a genuine bugfix, but I do not yet understand all 
> this well enough to do so right now. Maybe John will chime in with a 
> good solution.
I think the relevant questions are these:
Is there a reason that add_collection doesn't reset the dataLim?
Is there a reason that axes.cla() doesn't reset the dataLim?
The fix will depend on those answers. I'd like to see both done.
John?
Thanks for your help, Eric.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
 		
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: John H. <jdh...@ac...> - 2006年02月01日 19:08:07
>>>>> "Panos" == Panos Kassianidis <pk...@in...> writes:
 Panos> Hello everybody, I would like to use a solid line to plot a
 Panos> pulse. In other words let's say I have a number of zeros
 Panos> and ones and I would like to connect them like this with
 Panos> solid lines:
use the plot kwarg steps, eg, 
 plot(range(10), range(10), linestyle='steps')
JDH
From: sophana <so...@zi...> - 2006年02月01日 17:46:35
I've run the two-scale demo, but there is a big problem when I zoom into 
it (in the gtk gui): Only one of the 2 scales (the left one) changes.
Is there a way to select/zoom/move the second scale?
I changed the date_demo.py to display 2 stock quotes, but it is actualy 
unusable because of this.
Any help welcome
Paul Barrett wrote:
> Hello Andrea,
>
> Have you looked at the file, two_scales.py, in the examples 
> directory? This example would appear to show you how to create plots 
> with two or more scales per axis.
>
> -- Paul
>
> On 1/28/06, *Andrea Gavana* <and...@ti... 
> <mailto:and...@ti...>> wrote:
>
> Hello NG,
>
> please excuse my poor knowledge of matplotlib. I am searching
> for a way
> to do plots with multiple Y axes: for those of you that use
> Matlab, I am
> looking for something like plotyy and, if it's possible, also
> something more
> complicated like plotyyy or ploty4 (available at Matlab Central File
> Exchange) that allow you to put a third and fourth Y-axis on a
> plot, like in
> this screenshot:
>
> http://www.mathworks.de/matlabcentral/fileexchange/util.do?objectId=4425&imgName=plot4y.png
> <http://www.mathworks.de/matlabcentral/fileexchange/util.do?objectId=4425&imgName=plot4y.png>
>
> Is something like this possible with matplotlib? Is there anyone
> that has a
> small example on how to do it?
>
> Thank you in advance for every suggestion.
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against Reality."
> http://xoomer.virgilio.it/infinity77
> <http://xoomer.virgilio.it/infinity77>
>
>
>
> -- 
> Paul Barrett, PhD Johns Hopkins University
> Assoc. Research Scientist Dept of Physics and Astronomy
> Phone: 410-516-5190 Baltimore, MD 21218 
From: Victoria G. L. <la...@st...> - 2006年02月01日 16:15:29
Hi folks,
I frequently need to make a vector plot that shows (dx,dy) displacements 
from a set of (x,y) points. "Quiver" doesn't seem to do quite what I 
want, although maybe I just can't figure out how to use it.
 Anyhow here is a function I wrote to do what I want using the pylab 
interface, in case it can be cleaned up and incorporated into matplotlib 
for general use.
def vectorplot(x,y,dx,dy,scale=1):
 """ Generate a vector plot with lines emanating from the (x,y)
 points that represent the (dx,dy) displacement at each point.
 @param scale: Multiply (dx,dy) by this factor to make the displacements
 more visible
 @return: (cell_handle, displacement_handle) which can be used
 to pass to "legend"
 """
 u=x+scale*dx
 v=y+scale*dy
 #loop through to make the plots
 for i in range(len(x)):
 dhandle=plot([x[i],u[i]],[y[i],v[i]],'o-b',
 label='shifts [* %4.1f]'%scale)
 #then overplot the origin points in a different color
 chandle=plot(x,y,'sk',label='zone')
 return (chandle,dhandle)
cheers,
Vicki Laidler
From: Stefan v. d. W. <st...@su...> - 2006年02月01日 15:59:43
Thanks, Charlie. I tried 0.9.5.2024 and it works fine.
Cheers
St=E9fan
On Wed, Feb 01, 2006 at 10:44:59AM -0500, Charlie Moad wrote:
> MPL 0.86.2 is tested against numpy 0.9.4, so could please test with
> that release and let us know if you still have problems?
>=20
> Thanks,
> Charlie
>=20
> On 2/1/06, Stefan van der Walt <st...@su...> wrote:
> > Hi
> >
> > I am trying to get matplotlib working with numpy. When trying a
> > simple plot, I get the following error:
From: Charlie M. <cw...@gm...> - 2006年02月01日 15:45:11
MPL 0.86.2 is tested against numpy 0.9.4, so could please test with
that release and let us know if you still have problems?
Thanks,
 Charlie
On 2/1/06, Stefan van der Walt <st...@su...> wrote:
> Hi
>
> I am trying to get matplotlib working with numpy. When trying a
> simple plot, I get the following error:
>
> /home/stefan/lib/python2.4/site-packages/matplotlib/lines.py in set_data(=
self, *args)
> 274 my =3D ma.getmask(y)
> 275 mask =3D ma.mask_or(mx, my)
> --> 276 if mask is not ma.nomask:
> 277 x =3D ma.masked_array(x, mask=3Dmask).compressed()
> 278 y =3D ma.masked_array(y, mask=3Dmask).compressed()
>
> AttributeError: 'module' object has no attribute 'nomask'
>
> In [29]: matplotlib.__version__
> Out[29]: '0.86.2'
>
> In [30]: numpy.__version__
> Out[30]: '0.9.3.1881'
>
> I suppose ma.nomask does not exist in numpy. What is the best
> workaround?
>
> Thanks for your time.
> St=E9fan
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi=
les
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmdlnk&kid=103432&bid#0486&dat=121642
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Stefan v. d. W. <st...@su...> - 2006年02月01日 15:39:02
Hi
I am trying to get matplotlib working with numpy. When trying a
simple plot, I get the following error:
/home/stefan/lib/python2.4/site-packages/matplotlib/lines.py in set_data(=
self, *args)
 274 my =3D ma.getmask(y)
 275 mask =3D ma.mask_or(mx, my)
--> 276 if mask is not ma.nomask:
 277 x =3D ma.masked_array(x, mask=3Dmask).compressed()
 278 y =3D ma.masked_array(y, mask=3Dmask).compressed()
AttributeError: 'module' object has no attribute 'nomask'
In [29]: matplotlib.__version__
Out[29]: '0.86.2'
In [30]: numpy.__version__
Out[30]: '0.9.3.1881'
I suppose ma.nomask does not exist in numpy. What is the best
workaround?
Thanks for your time.
St=E9fan
From: John H. <jdh...@ac...> - 2006年02月01日 15:22:35
>>>>> "Vidar" == Vidar Gundersen <vid...@37...> writes:
 Vidar> i was wondering a bit about how to treat missing data when
 Vidar> loading or saving data with pylab. numarray has a module
 Vidar> for representing NaN, Inf (and i guess numpy have it). but
 Vidar> what about reading files with missing data, or NaNs?
The latest matplotlib allows you to pass converter functions into load
so you could write a custom one along the lines of 
def float_or_nan(x):
 if x=='None': return nan
 else: return float(x)
You could write something similar for save
 Vidar> another note on pylab.load(): wouldn't it be fairly easy to
 Vidar> detect the delimiter symbol automatically?
Probably -- let's see it :-)
JDH
From: Vidar G. <vid...@37...> - 2006年02月01日 15:03:35
i was wondering a bit about how to treat missing data
when loading or saving data with pylab.
numarray has a module for representing NaN, Inf (and
i guess numpy have it). but what about reading files with
missing data, or NaNs?
another note on pylab.load(): wouldn't it be fairly easy
to detect the delimiter symbol automatically?
From: Eric F. <ef...@ha...> - 2006年02月01日 08:36:31
Attachments: CBtest.py
Christopher Barker wrote:
> Christopher Barker wrote:
> 
>> Maybe I'll try to make a small sample that demonstrates the issue. 
>> stay tuned.
> 
> 
> OK, read the previous posts for background, or ignore them, and just 
> read this one. I made a small sample, and found that using a 
> LineCollection with axes.add_collection does something weird to the data 
> limits that axes sets. I've enclosed a small sample that demonstrates 
> the problem.
Chris,
Attached is a slight modification of your test case, with annotations. 
I think it does what you want--sort of. But I agree that there is a 
bug. After chasing references backwards and forwards through axes.py, 
axis.py, ticker.py, and _transforms.cpp, I don't quite understand how 
everything works, but I think this is part of the problem:
axes.has_data() is being used to determine whether to update the dataLim 
from scratch, or to start with previous values. axes.has_data() is True 
if any drawing artist (Line, Collection, etc.) has been added to the 
axes. So, after clearing the axes, adding a LineCollection tells the 
dataLim update method (called by the subsequent plot()) to use the old 
information, even though Collections (unlike Lines) do not change the 
dataLim. In other words, in your original script, I think that adding 
the collection was preventing plot() from setting the axes to a smaller 
value.
Workarounds: either set the dataLim explicitly, or add the collection 
after the plot command (as in the attached modified script). The latter 
only works if the plot command sets the dataLim to be large enough to 
cover everything in the collection.
I would like to make a genuine bugfix, but I do not yet understand all 
this well enough to do so right now. Maybe John will chime in with a 
good solution.
Eric
From: Christopher B. <Chr...@no...> - 2006年02月01日 01:01:23
Just for the record, I've solved all this, for the moment, by clearing 
the entire figure, and starting again with a brand new axes. It does 
seem like there's a bug in the axes.clear() method, however, I should be 
able to just .clear() and add stuff again, shouldn't I?
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
 		
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Christopher B. <Chr...@no...> - 2006年02月01日 00:44:18
Attachments: test.py
Christopher Barker wrote:
> Maybe I'll try to make a small sample that demonstrates the issue. stay 
> tuned.
OK, read the previous posts for background, or ignore them, and just 
read this one. I made a small sample, and found that using a 
LineCollection with axes.add_collection does something weird to the data 
limits that axes sets. I've enclosed a small sample that demonstrates 
the problem.
Here is the plotting code itself:
# Do some plotting
ax.plot(offsets[:,0], offsets[:,1], 'o')
# clear the axes, and try again, with different data.
ax.clear()
offsets *= .1
coll = LineCollection(segments, offsets=offsets,
 transOffset=ax.transData, # transforms the x,y 
offsets
 )
# points/72.*dpi = pixels -- see matplotlib.transforms
trans = scale_transform(fig.dpi/Value(72.), fig.dpi/Value(72.))
coll.set_transform(trans) # the points to pixels transform
ax.add_collection(coll)
ax.plot(offsets[:,0], offsets[:,1], 'o')
ax.autoscale_view()
pylab.show()
running this, you get the axes set to data limits appropriate to the 
first ax.plot call, before the ax.clear() call. (the second has values 
1/10 as large.
However, if you don't do the first plot call, it all scales correctly. 
Now it's even weirder. If you do the first plot call (with the larger 
data), but comment out add_collection() call, it scales correctly. So it 
seems that using add_collection someone fixes the data limits to the 
previous value, even after the ax.clear() call. AFAICT, looking at the 
axes class code, this shouldn't happen. add_collection doesn't do much 
at all.
Also, after axes.clear() is called, ax.has_data() returns False, so when
axes.update_datalim is called, the old dataLim should be ignored.
by the way, it looks like axes.cla() should perhaps have this in it:
self.dataLim = unit_bbox()
or maybe:
self._set_lim_and_transforms()
I've gotten a bit lost in all this: HELP!
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
 		
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
1 message has been excluded from this view by a project administrator.

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