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





Showing 14 results of 14

From: Chris B. <Chr...@no...> - 2005年02月22日 23:05:13
John,
Thanks for the reply. Sorry for the delay, I've been off line for a few 
days.
John Hunter wrote:
>>>>>>"Chris" == Chris Barker <Chr...@no...> writes:
> Chris> Hi all, Is there a way to get the size of a text object?
> Do you mean the width and height
> in points?
At this point, points. The other option is figure coordinates. The 
problem at hand is that we're generating a figure that has some fairly 
large labels on the Y axis, so we're having to do the layout of subplots 
ourselves. We've got it looking OK with trial and error, but if we 
change a label, it might not layout right anymore, so I thought it would 
be helpful to be able to check the sizes of things to do it automagically.
Besides, aren't there methods to convert between the various coord. 
systems anyway?
> but could be screwed up by a figure resize.
Yeah, it would , but right now I'm working with the AGG backend, so I 
can stick with one figure size.
> FYI, this is an issue that crops up a lot and is vexing. What one
> would like to be able to do is use a layout engine and say, place
> object one above and to the right of object 2 with a pad of 2 points.
Yes, that would be nice. In fact, I've been planning to do exactly that 
for my wxFloatCanvas. It's easier there because I've only got wx as a 
back end, but still a bit tricky. One thing I've done to help is simply 
declare that I'm always assuming 72dpi, rather than trying to use the 
system's idea of the display resolution. This has helped keep results 
consistent across systems. I have had to re-scale text, however.
> The text instance can give you its bounding box in display if you pass
> it the backend renderer -- this is required because the width and
> height can be backend dependent. I suppose you are using OO agg based
> on your previous posts.
Mostly, it's a mix as I'm working with someone else and most of the 
examples are in the pylab interface.
> One problem with the current design that is
> that the agg canvas doesn't generate it's renderer until draw time
> (with caching), but you need access to the renderer before draw time
> for layout that depends on text.
Right. So, do any of the default layout's take text into account 
(subplot, for example?)
 > If we move this logic to a
> get_renderer method, you can use it at draw time. I'll attach a
> replacement backend_agg.FigureCanvasAgg class to support this below
> 
> from matplotlib.figure import Figure
> from matplotlib.backends.backend_agg import FigureCanvasAgg
> 
> fig = Figure()
> canvas = FigureCanvasAgg(fig)
Didn't you add canvas as a Figure() attribute to support the new 
Figure.savefig() method? (added for me, such service!)
> renderer = canvas.get_renderer()
> ax = fig.add_subplot(111)
> ax.plot([1,2,3])
> t = ax.text(1,2,'hi mom')
> bbox = t.get_window_extent(renderer)
> print 'display', bbox.get_bounds() #l,b,w,h
> 
> # get the axes data coords bbox of this display bounding box
> from matplotlib.transforms import inverse_transform_bbox
> axbox = inverse_transform_bbox(ax.transData, bbox)
> 
> print 'data coords', axbox.get_bounds()
> 
> fig.savefig('test')
Thanks for this example. I hope I"ll get a chance to play with this 
soon. My schedule is a nightmare for a while.
thanks,
-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: Todd M. <jm...@st...> - 2005年02月22日 22:29:15
On Tue, 2005年02月22日 at 16:46, Perry Greenfield wrote:
> > - Are Numeric and numarray MAs similar enough to be used at the
> > C-API level, which is where agg would be checking the mask? Does
> > anyone know whether MAs will be part of the Numeric3 core? I
> > haven't seen any reference to them in the PEP.
> >
> We'll have to raise it. I imagine that they should be. As I mentioned, 
> NaNs don't solve all the problems that MA does. Since MA is layered on 
> Numeric/numarray it shouldn't be hard to do so. As far as C-API, since 
> it is a Python implementation, I presume it comes down to whether or 
> not the needed attributes are the same for the numeric and Numarray 
> variants. I'm not immediately familiar with that, but Todd should be 
> able to give a fairly quick answer on that (he did the port to 
> numarray)
As Perry said, numarray.ma is a port of MA to numarray so they're
fairly close. Both packages are pure Python layered over ordinary
numarray or Numeric numerical arrays. Accessing from C, both packages
should yield data or mask information via a method callback. The
resulting arrays are PyArrayObjects which are source compatible only: 
extensions using MA component arrays will need to be compiled for either
Numeric or numarray as we do now for _image, _transforms, and _contour.
Todd
From: Perry G. <pe...@st...> - 2005年02月22日 21:48:43
On Feb 22, 2005, at 4:21 PM, John Hunter wrote:
>>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
>
> Perry> As far as keyword args go, it seems to me that they would
> Perry> be more convenient in many cases, but as Stephen mentions,
> Perry> may be a fair amount of work (and in essence, they are an
> Perry> attribute of the data, so that may be where they belong).
>
> In the context of plotting, it isn't clear that NaNess is an attribute
> of the data. If the data are y = sin(2*pi*t), then NaNess enters only
I meant masks were an attribute of the data, but not NaNs (in other 
words, the way MA handles it may be the most appropriate)
Perry
From: Perry G. <pe...@st...> - 2005年02月22日 21:45:40
On Feb 22, 2005, at 4:21 PM, John Hunter wrote:
>>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
>
> Perry> As far as keyword args go, it seems to me that they would
> Perry> be more convenient in many cases, but as Stephen mentions,
> Perry> may be a fair amount of work (and in essence, they are an
> Perry> attribute of the data, so that may be where they belong).
>
> In the context of plotting, it isn't clear that NaNess is an attribute
> of the data. If the data are y = sin(2*pi*t), then NaNess enters only
> under certain transformations (eg log) of the data. From my
> perspective, or the perspective of a matplotlib Line, the data are
> intact, it is just that under certain transformations the data are
> invalid. Thus the mask is only needed under certain views
> (transformations) which the Line class is mostly unaware of. I think
> there are two cases to be distinguished: the case Eric mentioned where
> some data points are NaN or None because the measurements are missing
> or invalid, and the case where the data are valid but are nan under
> certain transformations.
>
Right.
> For the latter, it would be maximally useful to be able to do
>
> #x,y,xt,yt are numerix arrays; transform puts in NaN on domain error
> xt, yt = transform(x, y)
>
> and the drawing routine drops NaN points and handles the connecting
> segments properly. That it only works for float arrays is not a
> problem since that is what we are using, eg in the line class
>
> self._x = asarray(x, Float)
> self._y = asarray(y, Float)
>
> but it is my current understanding that this ain't gonna happen in a
> consistent way for Numeric, Numeric3, and numarray across platforms,
> because my brief forays into researching this issue turned up posts by
> Tim Peters saying that there was no standard way of dealing with IEEE
> 754 special values across compilers. If that's true, and we can't fix
> it or work around it, then I think boolean masks passed as a kwarg may
> be the easiest way to handle this across various numerix
> implementations, assuming that Numeric3 comes to fruition and assuming
> that there isn't a consistent MA approach that is accessible at the
> API level, which I don't know to be true but I get the feeling that
> this is a reasonable guess.
>
I think you may be over-extending what Tim was saying. I believe the 
issue is writing C code that handles things like tests against NaN 
values correctly. In that, Tim is right, there is a great deal of 
inconsistency in how C compilers handle ieee special values. But 
generally speaking, the computations *are* handled consistently by the 
floating point processors. numarray solved this problem by not relying 
on the C compiler to test or set NaN values (it tests raw bit patterns 
instead) and so should handle this issue properly. Numeric doesn't, but 
Numeric3 is planned to. So I think NaNs can't be handled right now 
because of Numeric, but I don't think the C compiler issue that Tim 
mentions is a roadblock (it is a nuisance for implementation though)..
> I'd be interested in getting feedback from those of you who have
> informed opinions on these matters:
>
> - Is it possible to handle NaN in Numeric/numarray arrays across the
>
> big three platforms? I'm pretty sure the answer here is no.
>
No for Numeric, yes for numarray/Numeric3
> - Are Numeric and numarray MAs similar enough to be used at the
> C-API level, which is where agg would be checking the mask? Does
> anyone know whether MAs will be part of the Numeric3 core? I
> haven't seen any reference to them in the PEP.
>
We'll have to raise it. I imagine that they should be. As I mentioned, 
NaNs don't solve all the problems that MA does. Since MA is layered on 
Numeric/numarray it shouldn't be hard to do so. As far as C-API, since 
it is a Python implementation, I presume it comes down to whether or 
not the needed attributes are the same for the numeric and Numarray 
variants. I'm not immediately familiar with that, but Todd should be 
able to give a fairly quick answer on that (he did the port to 
numarray)
Perry
From: John H. <jdh...@ac...> - 2005年02月22日 21:33:15
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
 Perry> As far as keyword args go, it seems to me that they would
 Perry> be more convenient in many cases, but as Stephen mentions,
 Perry> may be a fair amount of work (and in essence, they are an
 Perry> attribute of the data, so that may be where they belong).
In the context of plotting, it isn't clear that NaNess is an attribute
of the data. If the data are y = sin(2*pi*t), then NaNess enters only
under certain transformations (eg log) of the data. From my
perspective, or the perspective of a matplotlib Line, the data are
intact, it is just that under certain transformations the data are
invalid. Thus the mask is only needed under certain views
(transformations) which the Line class is mostly unaware of. I think
there are two cases to be distinguished: the case Eric mentioned where
some data points are NaN or None because the measurements are missing
or invalid, and the case where the data are valid but are nan under
certain transformations.
For the latter, it would be maximally useful to be able to do
 #x,y,xt,yt are numerix arrays; transform puts in NaN on domain error
 xt, yt = transform(x, y) 
 
and the drawing routine drops NaN points and handles the connecting
segments properly. That it only works for float arrays is not a
problem since that is what we are using, eg in the line class
 self._x = asarray(x, Float)
 self._y = asarray(y, Float)
but it is my current understanding that this ain't gonna happen in a
consistent way for Numeric, Numeric3, and numarray across platforms,
because my brief forays into researching this issue turned up posts by
Tim Peters saying that there was no standard way of dealing with IEEE
754 special values across compilers. If that's true, and we can't fix
it or work around it, then I think boolean masks passed as a kwarg may
be the easiest way to handle this across various numerix
implementations, assuming that Numeric3 comes to fruition and assuming
that there isn't a consistent MA approach that is accessible at the
API level, which I don't know to be true but I get the feeling that
this is a reasonable guess.
I'd be interested in getting feedback from those of you who have
informed opinions on these matters:
 - Is it possible to handle NaN in Numeric/numarray arrays across the
 big three platforms? I'm pretty sure the answer here is no.
 - Are Numeric and numarray MAs similar enough to be used at the
 C-API level, which is where agg would be checking the mask? Does
 anyone know whether MAs will be part of the Numeric3 core? I
 haven't seen any reference to them in the PEP.
JDH
From: Perry G. <pe...@st...> - 2005年02月22日 21:03:55
On Feb 21, 2005, at 7:00 PM, Eric Firing wrote:
>
> Stephen,
>
>>> Are you suggesting something like this? Let each plotting function 
>>> have a new kwarg, perhaps called "validmask", with the same 
>>> dimensions as the dependent variable to be plotted, and with nonzero 
>>> where the variable is valid and 0 where it is missing.
>> More or less, except that the mask is an attribute (?) of a 
>> MaskedArray object. I for one would be in favor of this capability.
>
> I agree that this is an alternative, but I am not sure that it is 
> better than what I described. It requires all the machinery of the 
> ma/MA module, which looks cumbersome to me. What does it gain? max 
> and min will do the right thing on the masked array input, so one 
> would not have to duplicate this inside matplotlib. It is not hard to 
> duplicate, however. How much more ma/MA functionality would actually 
> be useful?
>
> When it was originally developed, the MaskedArray may have been a good 
> way to get past Numeric's lack of nan-handling. In the long run, 
> however, it seems to me that Python needs a numeric module with good 
> nan-handling (as in Matlab and Octave), and that this will render the 
> Masked Array obsolete. If so, then specifying a mask as a kwarg in 
> matplotlib, and not using MA internally, may be simpler, more robust, 
> and more flexible.
>
> The user would still be free to use MA/ma externally, if desired.
>
> A variation would be to support MA/ma in matplotlib only to the extent 
> of checking for a MaskedArray input, and if it is present, breaking it 
> apart and using the mask as if it had come via the kwarg. One could 
> use either the kwarg or a Masked Array.
>
When we looked at the issue of using NaNs in place of masks or masked 
arrays, we concluded (well, I did anyway) that while NaNs could be used 
to replace masks in many instances, they could not be used in all. 
There are a lot of cases where people want to retain the value being 
masked (e.g., to do statistics on the rejected values). NaNs as masks 
only work for float and complex, not ints. So both approaches are 
useful and needed as far as I can tell.
As far as keyword args go, it seems to me that they would be more 
convenient in many cases, but as Stephen mentions, may be a fair amount 
of work (and in essence, they are an attribute of the data, so that may 
be where they belong).
Perry
From: Darren D. <dd...@co...> - 2005年02月22日 20:41:36
On Tuesday 22 February 2005 01:47 pm, John Hunter wrote:
> >>>>> "Darren" == Darren Dale <dd...@co...> writes:
>
> Darren> Hi, I am reporting a minor bug. I noticed that if I change
> Darren> the ticklabel size to 10, draw a semilogy plot, and save
> Darren> an eps file, that the yticklabels in the eps are badly
> Darren> formatted. The exponent runs into the base.
>
[...]
>
> The relevant section of code is matplotlib.text.Text._get_layout_super
[...]
> see if you can find something that works well for a variety of
> reasonable font sizes. You might want to make the pad dependent on
> the fontsize...
The following conditions will work for eps files, however, the labels in the 
plot on the screen are adversely effected.
 if size<12: xe = xb+1.3*wb
 elif size==16: xe = xb+1.175*wb
 else: xe = xb+1.125*wb
 ye = yb+0.5*hb
Is it possible that the translation to postscript is what needs to be 
modified?
Darren
From: John H. <jdh...@ac...> - 2005年02月22日 18:58:42
>>>>> "Darren" == Darren Dale <dd...@co...> writes:
 Darren> Hi, I am reporting a minor bug. I noticed that if I change
 Darren> the ticklabel size to 10, draw a semilogy plot, and save
 Darren> an eps file, that the yticklabels in the eps are badly
 Darren> formatted. The exponent runs into the base.
 Darren> from matplotlib import * rc('tick',labelsize=10) from
 Darren> pylab import *
 Darren> semilogy([1,2,3],[1e-5,1,1e5]) savefig('temp.eps')
The relevant section of code is matplotlib.text.Text._get_layout_super
 wb,hb = renderer.get_text_width_height(base, self._fontproperties, False)
 we,he = renderer.get_text_width_height(exponent, fpexp, False)
 w = wb+we
 xb, yb = self._transform.xy_tup((self._x, self._y))
 xe = xb+wb
 ye = yb+0.5*hb
 h = ye+he-yb
w,h is width and height and e,b is exponent and base -- eg, xb is the
x location of the base and wb is the width of the base. Try adding a
pad to xe, eg
 xe = xb+1.05*wb
and see if you can find something that works well for a variety of
reasonable font sizes. You might want to make the pad dependent on
the fontsize...
JDH
>>>>> "Eric" == Eric Firing <ef...@ha...> writes:
 Eric> Perry, John, Progress! 
Cool!
 Eric> I found that the problem I was having with PolyCollection
 Eric> was this: the vertices argument must be a sequence (list or
 Eric> tuple) of tuples of tuples--if one gives it a list of
 Eric> *lists* of tuples, one gets
 Eric> [first part of trace omitted] File
 Eric> "/usr/lib/python2.3/site-packages/matplotlib/collections.py",
 Eric> line 205, in draw self._offsets, self._transOffset)
 Eric> TypeError: CXX: type error
 Eric> (The line number was smaller before I put in some debugging
 Eric> print statements.)
 Eric> I think this fussiness qualifies as a bug; the docstring for
 Eric> PolyCollection says vertices can be a sequence of sequences
 Eric> of tuples. I don't know what the right way to fix it is,
 Eric> however, so I am working around it.
Fair enough -- I just fixed all the agg collection drawing routines to
work with the sequence API and not require tuples. Glad to see you're
making progress -- poly contouring is something I'd like to see added.
 Eric> Having solved that problem, I am getting more optimistic
 Eric> about being able to come up with a usable filled contour
 Eric> capability fairly quickly. Still no promises, though.
Great -- be mindful of the contourf matlab docstrings. Strict
adherence is not required, but it is nice to be compatible where
possible.
 Eric> All this brings to mind a question that has puzzled me for a
 Eric> long time: why does matplotlib internally use sequences of
 Eric> (x,y) tuples instead of numerix arrays--either a 2-D array,
 Eric> or a pair (or tuple) of 1-D arrays? I would think that
 Eric> running all plotted numbers through the conversion from
 Eric> arrays to Python tuples, and then from there into the native
 Eric> data types for each backend, would incur a big performance
 Eric> penalty when plotting large numbers of points. Not that I
 Eric> am suggesting a redesign--I am just curious.
Historical and other reasons. The historical part is that this part
of the code was written before Todd had solved the numeric/numarray
API compatibility problem for matplotlib. These are now solved, 've
been slowly adding some numerix code to backend agg, most recently in
0.72. I don't think it would make a lot of difference for
collections. In the first place, you'd have to create all these lists
of numarray lists, since the collection is by definition a list of
disconnected lines. In the second place, there is a fair amount going
on in the inner loop that I think would offset the gains you get from
using numeric. In draw_lines, where the x,y access is a major part of
the inner loop, I do use numerix.
The backend API is moving to a path drawing model, which may obviate
the need for specialized collection drawing methods. The collection
interface would remain unchanged, but we might get away w/o having
special methods to draw them.
JDH
From: Stephen W. <ste...@cs...> - 2005年02月22日 14:35:16
Stephen Walton wrote, in the context of using masked arrays rather than 
a keyword argument which would be the mask:
> It would be more flexible. Instead of having to actually replace data 
> with NaN, you could create a mask which marked data to be ignored for 
> the moment:
This is, of course, incorrect. Both approaches would allow arbitrary 
data sets to be masked as needed.
There was a mention over on an astronomy group of the progress being 
made in masked astronomical images. Here too, the mask "comes along" 
with the data. Perry et al., does STScI anticipate using 
numarray/Numeric masked arrays within PyFITS to handle this?
From: Eric F. <ef...@ha...> - 2005年02月22日 04:14:50
Perry, John,
Progress! I found that the problem I was having with PolyCollection was 
this: the vertices argument must be a sequence (list or tuple) of tuples 
of tuples--if one gives it a list of *lists* of tuples, one gets
[first part of trace omitted]
 File "/usr/lib/python2.3/site-packages/matplotlib/collections.py", 
line 205, in draw
 self._offsets, self._transOffset)
TypeError: CXX: type error
(The line number was smaller before I put in some debugging print 
statements.)
I think this fussiness qualifies as a bug; the docstring for 
PolyCollection says vertices can be a sequence of sequences of tuples. 
I don't know what the right way to fix it is, however, so I am working 
around it.
Having solved that problem, I am getting more optimistic about being 
able to come up with a usable filled contour capability fairly quickly. 
Still no promises, though.
All this brings to mind a question that has puzzled me for a long time: 
why does matplotlib internally use sequences of (x,y) tuples instead of 
numerix arrays--either a 2-D array, or a pair (or tuple) of 1-D arrays? 
I would think that running all plotted numbers through the conversion 
from arrays to Python tuples, and then from there into the native data 
types for each backend, would incur a big performance penalty when 
plotting large numbers of points. Not that I am suggesting a 
redesign--I am just curious.
Eric
From: Darren D. <dd...@co...> - 2005年02月22日 04:13:14
Hi,
I am reporting a minor bug. I noticed that if I change the ticklabel size to 
10, draw a semilogy plot, and save an eps file, that the yticklabels in the 
eps are badly formatted. The exponent runs into the base.
from matplotlib import *
rc('tick',labelsize=10)
from pylab import *
semilogy([1,2,3],[1e-5,1,1e5])
savefig('temp.eps')
-- 
Darren
From: Stephen W. <ste...@cs...> - 2005年02月22日 03:05:49
Hello,
>
> I agree that this is an alternative, but I am not sure that it is 
> better than what I described. It requires all the machinery of the 
> ma/MA module, which looks cumbersome to me. What does it gain?
It would be more flexible. Instead of having to actually replace data 
with NaN, you could create a mask which marked data to be ignored for 
the moment: all negative values, say, or all values with a complex part 
less than 1e-5. Much more flexible. Having said that, I agree that NaN 
should also be ignored wherever it occurs.
> One could use either the kwarg or a Masked Array.
-1 on the kwarg. It seems to me that adding it to every plot command 
uglifies the interface significantly as well as being more work for John.
Stephen
From: Eric F. <ef...@ha...> - 2005年02月22日 00:01:05
Stephen,
>> Are you suggesting something like this? Let each plotting function 
>> have a new kwarg, perhaps called "validmask", with the same dimensions 
>> as the dependent variable to be plotted, and with nonzero where the 
>> variable is valid and 0 where it is missing.
> 
> 
> More or less, except that the mask is an attribute (?) of a MaskedArray 
> object. I for one would be in favor of this capability.
I agree that this is an alternative, but I am not sure that it is better 
than what I described. It requires all the machinery of the ma/MA 
module, which looks cumbersome to me. What does it gain? max and min 
will do the right thing on the masked array input, so one would not have 
to duplicate this inside matplotlib. It is not hard to duplicate, 
however. How much more ma/MA functionality would actually be useful?
When it was originally developed, the MaskedArray may have been a good 
way to get past Numeric's lack of nan-handling. In the long run, 
however, it seems to me that Python needs a numeric module with good 
nan-handling (as in Matlab and Octave), and that this will render the 
Masked Array obsolete. If so, then specifying a mask as a kwarg in 
matplotlib, and not using MA internally, may be simpler, more robust, 
and more flexible.
The user would still be free to use MA/ma externally, if desired.
A variation would be to support MA/ma in matplotlib only to the extent 
of checking for a MaskedArray input, and if it is present, breaking it 
apart and using the mask as if it had come via the kwarg. One could use 
either the kwarg or a Masked Array.
Eric

Showing 14 results of 14

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