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

Showing 14 results of 14

From: John H. <jdh...@ac...> - 2004年04月20日 22:46:37
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
 Perry> While not common, it does happen. I'm reminded of a
 Perry> handbook that was produced here that generated an incorrect
 Perry> plot because of a clipping error. We didn't write that
 Perry> clipping software, but it was embarrasing nonetheless. It's
 Perry> worth some effort to get it right I think. Before wasting
 Perry> more discussion over it I guess I'd like to know which
 Perry> backends don't support generalized clipping for lines and
 Perry> polygons.
I'll delve deeper into agg and find out what exactly is going.
BTW, Maxim has revamped the antigrain site, added documentation, and
released some new code. I'm obviously waiting until the dust settles
on the next matlotlib release before upgrading (and upgrading
matplotlib agg cvs will be a bit of a pain since many file names hanve
changed).
 http://antigrain.com
JDH
From: Perry G. <pe...@st...> - 2004年04月20日 21:52:33
John Hunter writes:
> In Srinath's case, we've asked the backend to plot, for example, a
> line from (0,-50000), (0,100) and then clip to the (25,25) (75,75)
> rectangle. I don't think the average backend (GTK, Agg) knows what to
> do with this line since they expect bitmap/display coords; there are
> no backend transformations - everything happens on the front end
> (clearly there are pros and cons of this approach, see below).
>
Hmmm, I've always figured that true clipping works with arbitrary
coordinates, that it does handle exactly the problem that
Srinath reports; when it doesn't then the clipping algorithm
is not really fully implemented. I'm almost certain that OpenGL
handles this correctly and would be surprised if postscript didn't
as well. Is it true that agg will only clip positive coordinates
correctly? If so I'm surprised. Some GUIs may not, but I would
have thought this is standard for any graphics system. On the
other hand, I admit to the possibility of being completely wrong
about this. I'll look up the postscript situation. You are much
more familiar with agg than I am, though (particularly since
agg documentation is not easily accessible).
> With data clipping turned, the line class throws out the (0,-50000)
> point as illegal.
>
> To fix this in the current framework, we have to identify line
> segments in the x,y arrays which intersect the view port but with one
> or more end points outside the viewlim, and then draw the appropriate
> line through view port. This issue primarily arises for connected
Tell me about it :-). I wrote a Python program to do just this for a
Chaco/kiva/Tk backend. Messy but doable. Clipping polygons is way
messier (many complex algorithms developed for that in the literature).
Performance was ok so long as the original curve didn't
get fragmented into too many segments. (Worst case: 100,000 points;
alternating one point out of range positive and the next out of
range negative).
> points (line styles '-', '--', and '-.' ). For symbol lines, data
> clipping already does the right thing, which is to throw the point
> away. However, there are hypothetical wacky cases you can imagine
> when you feel like being mean to matplotlib, like a 'o' circle marker
> 5 million miles from the view limits with a 5 million and one mile
> radius..... For connected lines, this could be very costly to
> implement since we have to loop over potentially very long arrays; for
> markers it would be worse.
>
This is a bad case. This is where you do need the polygon clipping
algorithm.
> Refactoring transforms to the backend would probably fix this
> entirely. While non-trivial, this may be the best long term solution,
> especially when we want to do things like line and patch collections
> for efficient drawing of large numbers of objects. The two major
> benefits of the current transform architecture are 1) it lets you
> specify locations like 5 points to the left of the right y axes, and
> have the transform automatically update in the presence of window
> resizes, dpi changes, etc... Very nice when drawing ticks.... and 2)
> backends only have to think about one coord system, display, which
> makes it easier to implement a backend.
>
I'm not sure this is needed if all the important backends (i.e.,
Agg-based, postscript, svg, ...) support this capability. Users
are warned that clipping doesn't work well for the other backends
or the backend calls call clipping functions on their data points
before calling the graphics primitives.
> I'm not convinced that it is a terrible thing to have a policy that
> matplotlib only plots line segments and markers whose vertices are in
> the axes limits, but I'm open to being convinced.
>
While not common, it does happen. I'm reminded of a handbook that
was produced here that generated an incorrect plot because of
a clipping error. We didn't write that clipping software, but it
was embarrasing nonetheless. It's worth some effort to get it
right I think. Before wasting more discussion over it I guess
I'd like to know which backends don't support generalized clipping
for lines and polygons.
Perry
From: John H. <jdh...@ac...> - 2004年04月20日 20:01:21
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
 Perry> Is the essence of the issue here whether clipping is
 Perry> working properly, in particular, the backend clipping? I
 Perry> would have thought that backend clipping should handle this
 Perry> properly. For which backends does it not? If it doesn't
 Perry> for some, perhaps the issue is to supply our own software
 Perry> clipping; algorithm (possibly much slower though) as an
 Perry> option.
Backend clipping works when the points are on the canvas (the canvas
is the entire figure, not just the axes). Eg, on a 100x100 canvas,
with a line from (0,0) to (100,100) you can clip to the (25,25)
(75,75) rectangle. No problems there.
In Srinath's case, we've asked the backend to plot, for example, a
line from (0,-50000), (0,100) and then clip to the (25,25) (75,75)
rectangle. I don't think the average backend (GTK, Agg) knows what to
do with this line since they expect bitmap/display coords; there are
no backend transformations - everything happens on the front end
(clearly there are pros and cons of this approach, see below).
With data clipping turned, the line class throws out the (0,-50000)
point as illegal.
To fix this in the current framework, we have to identify line
segments in the x,y arrays which intersect the view port but with one
or more end points outside the viewlim, and then draw the appropriate
line through view port. This issue primarily arises for connected
points (line styles '-', '--', and '-.' ). For symbol lines, data
clipping already does the right thing, which is to throw the point
away. However, there are hypothetical wacky cases you can imagine
when you feel like being mean to matplotlib, like a 'o' circle marker
5 million miles from the view limits with a 5 million and one mile
radius..... For connected lines, this could be very costly to
implement since we have to loop over potentially very long arrays; for
markers it would be worse.
Refactoring transforms to the backend would probably fix this
entirely. While non-trivial, this may be the best long term solution,
especially when we want to do things like line and patch collections
for efficient drawing of large numbers of objects. The two major
benefits of the current transform architecture are 1) it lets you
specify locations like 5 points to the left of the right y axes, and
have the transform automatically update in the presence of window
resizes, dpi changes, etc... Very nice when drawing ticks.... and 2)
backends only have to think about one coord system, display, which
makes it easier to implement a backend.
I'm not convinced that it is a terrible thing to have a policy that
matplotlib only plots line segments and markers whose vertices are in
the axes limits, but I'm open to being convinced.
JDH
From: Perry G. <pe...@st...> - 2004年04月20日 18:39:42
John Hunter writes:
> >>>>> "Srinath" == Srinath Avadhanula <sr...@fa...> writes:
> 
> Srinath> Besides whether or not its a common enough situation is
> Srinath> very application specific. I was planning to use
> Srinath> matplotlib to display a complex layout. At the original
> Srinath> scale, not much can be seen. There necessarily has to be
> Srinath> a lot of scaling to see the details.
> 
> Well, it's not complex scaling that causes troubles. The case where
> you see this failure is when you are drawing a connected line between
> two points where one or both of the points is far outside the view
> limits.
> 
Is the essence of the issue here whether clipping is working
properly, in particular, the backend clipping? I would have
thought that backend clipping should handle this properly.
For which backends does it not? If it doesn't for some,
perhaps the issue is to supply our own software clipping;
algorithm (possibly much slower though) as an option.
Perry
From: John H. <jdh...@ac...> - 2004年04月20日 13:48:21
>>>>> "Srinath" == Srinath Avadhanula <sr...@fa...> writes:
 Srinath> Besides whether or not its a common enough situation is
 Srinath> very application specific. I was planning to use
 Srinath> matplotlib to display a complex layout. At the original
 Srinath> scale, not much can be seen. There necessarily has to be
 Srinath> a lot of scaling to see the details.
Well, it's not complex scaling that causes troubles. The case where
you see this failure is when you are drawing a connected line between
two points where one or both of the points is far outside the view
limits.
 Srinath> Could you let me know which files in matplotlib have the
 Srinath> code in question? I'll take a look then.
The two relevant methods are matplotlib.transforms.Transform.positions
and matplotlib.lines.Line2D._draw. I think the best place to start
would be in the latter function. Let the transform do it's thing and
then look for negative points.
Note there are two kinds of clipping in matplotlib: data clipping and
view clipping. data clipping removes data outside the view limits
before transpose and plotting. view clipping is a renderer operation
that prevents lines from being drawn outside the axes box. data
clipping would remove a point from a connected line outside the
viewport and prevent any part of that line from being drawn, even the
part in the view port. view clipping would only clip the part that
extends outside the viewport.
The decision to use one or the other is often motivated by
performance. Eg, if you want to plot a very large data set with only
a small fraction in the viewport (which I often do), you often want to
use data clipping to reduce the data set before transform and
rendering. If you normally plot data with limits near the viewport
limits you probably do not want the extra performance overhead and are
happy with just view clipping which gives the "usual" result. That is
why it's a configurable parameter.
In earlier versions of matplotlib data clipping was on by default so
data outside the view ports was removed. That is probably why we
didn't see this negative transform error earlier. But experiments
revealed that in the most common cases, data clipping did not provide
an extra performance benefit, and occasionally surprised users in
cases very similar to yours where one point of a connected line was
outside the viewport and the entire line was removed.
Given that negative display coords are essentially undefined (and
backend dependent) at this point, I'm going to re-enable data clipping
in the default matplotlibrc file, and I suggest most users do the
same. There may be modulo operations on data points very far outside
the data set that generate negative display values, or display values
far larger than the display limits, each of which could cause artifact
points.
The ideal solution is yet to be found, but I'm open to suggestions and
improvements.
JDH
From: John H. <jdh...@ac...> - 2004年04月20日 13:29:39
>>>>> "Peter" == Peter Juvan <pet...@fr...> writes:
 Peter> I prefer pcolor over imshow - I need to represent values
 Peter> from a 12x12 matrix as colors. Please modify pcolor
 Peter> arguments to use a custom colormap. Where / when will I be
 Peter> able to obtain the modified version? -Peter
For 12x12 pcolor should work great. I included the pcolor cmap kwarg
for the next release, which is starting to look like tomorrow rather
than today .....
JDH
From: Peter J. <pet...@fr...> - 2004年04月20日 13:21:25
> From: John Hunter [mailto:jdh...@ac...] 
>
> Note, if you really need the
> functionality of pcolor over imshow (eg you want to set some
> properties on the rectangle patches), I can modify the pcolor argument
> list to use your custom colormap.
I prefer pcolor over imshow - I need to represent values from a 12x12 matrix
as colors. Please modify pcolor arguments to use a custom colormap. Where /
when will I be able to obtain the modified version? -Peter
From: John H. <jdh...@ac...> - 2004年04月20日 11:58:41
>>>>> "Peter" == Peter Juvan <pet...@fr...> writes:
 Peter> Q: Is it possible to change the default color scale of the
 Peter> matplotlib.matlab.pcolor plot? How? -Peter
You can define your own colormap by subclassing
matplotlib.colors.Colormap and then passing this to imshow in the cmap
argument. Note that for the most part pcolor and imshow have the same
functionality, but imshow is 1000 times faster for large grids.
Compare pcolor_demo.py and pcolor_demo2.py in the examples dir which
use pcolor and imshow respectively. Note, if you really need the
functionality of pcolor over imshow (eg you want to set some
properties on the rectangle patches), I can modify the pcolor argument
list to use your custom colormap.
If you define a new colormap (currently we have only jet and
grayscale), please send it back to the list so I can include it.
JDH
From: John H. <jdh...@ac...> - 2004年04月20日 11:53:21
>>>>> "Jaanus" == Jaanus Karo <jaa...@ph...> writes:
 Jaanus> Can I create graphs with two different y-axes?
Look for the 0.53 release later this afternoon. Download the src
distribution and see examples/two_scales.py.
JDH
>>>>> "Kenneth" == Kenneth McDonald <kmm...@wi...> writes:
 Kenneth> Couldn't see the answers to these questions when looking
 Kenneth> through the class reference docs, but they seem like
 Kenneth> common tasks, so I suspect there are standard idiomatic
 Kenneth> way of doing these. Could anyone refer me to examples
 Kenneth> showing
Actually, neither of these exist in matplotlib-0.52, but see below.
 Kenneth> 1) How to most easily label the x axis for data which is
 Kenneth> plotted by date? (More specifically; does matplotlib have
 Kenneth> any understanding of date values, and if so, how do I
 Kenneth> access and use it?) I'm hoping there's an easier way than
 Kenneth> explicitly labelling ticks on the x axis.
Full date support in matplotlib-0.53. Release should be this
afternoon. The new examples will be examples/date_demo*.py.
 Kenneth> 2) I'll be drawing logy graphs, and I want a certain
 Kenneth> slope to indicate a certain rate of growth, which means
 Kenneth> that, when using matplotlib via TkAgg, I want it to keep
 Kenneth> the ratio of the graph display height and display width
 Kenneth> constant as it resizes the graph to take into account
 Kenneth> changes in the size of the enclosing window. Is there a
 Kenneth> standard way to do this?
This is a good idea but it's not implemented and should be. How do
you think the best way is to indicate a constrained resize? With a
modifier key held down during the resize?
JDH
From: Peter J. <pet...@fr...> - 2004年04月20日 10:54:59
Q: Is it possible to change the default color scale of the
matplotlib.matlab.pcolor plot? How? -Peter
From: Jaanus K. <jaa...@ph...> - 2004年04月20日 09:38:03
Hello!
Can I create graphs with two different y-axes?
Jaanus
From: Kenneth M. <kmm...@wi...> - 2004年04月20日 06:51:52
Couldn't see the answers to these questions when looking through the
class reference docs, but they seem like common tasks, so I suspect
there are standard idiomatic way of doing these. Could anyone refer
me to examples showing
1) How to most easily label the x axis for data which is plotted
by date? (More specifically; does matplotlib have any understanding
of date values, and if so, how do I access and use it?) I'm hoping
there's an easier way than explicitly labelling ticks on the x axis.
2) I'll be drawing logy graphs, and I want a certain slope to indicate
a certain rate of growth, which means that, when using matplotlib
via TkAgg, I want it to keep the ratio of the graph display height
and display width constant as it resizes the graph to take into
account changes in the size of the enclosing window. Is there
a standard way to do this?
Thanks,
Ken McDonald
From: Kenneth M. <kmm...@wi...> - 2004年04月20日 05:33:34
Well, I finally have matplotlib up and running under OS X, and
am amazed at the quality of the graphs. I'm writing up a
summary of what I learned about Python/Tk/OS X, and will
post it to this and other lists in the next day or two.
Now, a real quick question; are there any tutorials or examples
which show the "correct" way of using matplotlibs pythonic (as
opposed to Matlabic) API? I don't know and don't want to learn
Matlab, so figure I might as well start by using the "pure"
python API. However, all of the examples I've looked at use
the Matlab style interface, and the reference docs don't
really give a good idea of _how_ the various Python
classes are intended to be used together.
Thanks,
Ken

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