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



Showing 19 results of 19

From: Mariusz S. <mar...@gm...> - 2012年02月28日 22:41:30
Hi
I am struggling with making graph transparent. Basically, i have wxpython
app with graph located on panel. The panel has bitmap background so i
wanted to get rid of white background of chart in order to make whole thing
nice looking.
However, i can't solve it. I was trying setting with patch.set_alpha or
set facecolor but no satisfying results.
Is there a way to get what i was trying to do?
Now i am thinkinig of generating png file and load to app but i would like
to avoid it
Thanks in advance for all clues
best regards
From: Moore, E. (NIH/N. [F] <eri...@ni...> - 2012年02月28日 22:36:39
I think that what you want can be achieved more simply than contouring. I've attached a quick example of how I would do this. I'm assuming that the data has the same form as pcolormesh, i.e, the z values are measured at grid centers but we have coordinate of the edges. This means that we can easily check if a given pixel is above or below the contour level and then we simply draw the appropriate gridlines. I'm not coalescing neighboring lines, but that's also possible. 
If you're looking for something more complex than this simple in-or-out partitioning, this approach might still work but I'm not sure, in that case, that I understand what you're actually trying to do. 
-Eric
p.s. two loops aren't necessary, really.
From: Benjamin R. <ben...@ou...> - 2012年02月28日 22:04:16
On Tue, Feb 28, 2012 at 3:48 PM, Mario Fuest <mar...@ao...> wrote:
> Hi there,
>
> Currently i use these commands to layout and save my figures:
>
> > figure
> > ...
> > gca.set_aspect('equal')
> > gca.autoscale(tight=True)
> > ...
> > plt.savefig('fpp.png', bbox_inches='tight', pad_inches=0)
>
> I would like to set the width of this png file, how to do that? If
> savefig() does not support setting the width, maybe I can set the width
> of my xaxis?
>
> Thanks in advance, Keba
>
>
The size of the PNG will be based on the size of your figure object. When
you create your figure, you can pass a figsize kwarg which takes a tuple of
width, height in inches (defaults to 8 x 6, I think).
fig = plt.figure(figsize=(10.0, 6.0))
I hope that helps!
Ben Root
From: Mario F. <mar...@ao...> - 2012年02月28日 21:52:33
Hi,
Sorry for the late reply.
Tony Yu <ts...@gm...> schrieb am Tue, 03. Jan 17:07:
> You can try
> 
> >>> ax.set_aspect('equal')
> >>> ax.autoscale(tight=True)
> 
> The order doesn't seem to matter.
That works well, thank you! :)
Kind regars, Keba.
From: Mario F. <mar...@ao...> - 2012年02月28日 21:49:16
Hi there,
Currently i use these commands to layout and save my figures:
 > figure
 > ...
 > gca.set_aspect('equal')
 > gca.autoscale(tight=True)
 > ...
 > plt.savefig('fpp.png', bbox_inches='tight', pad_inches=0)
I would like to set the width of this png file, how to do that? If
savefig() does not support setting the width, maybe I can set the width
of my xaxis?
Thanks in advance, Keba
From: Antoine S. <an...@mo...> - 2012年02月28日 21:21:01
Hi,
I have been using the event "draw_event" for a while with the old matplotlib 0.8. I have tested my program with newer versions but it seems the function connected to "draw_event" is never called.
You can find an example of this there: https://gist.github.com/1901504
With an old version the image color scale is rescaled when you zoom in. With matplotlib 1.x, no change is made on on the color scale.
Have I missed something?
Thanks in advance for your help.
Antoine
From: John H. <jd...@gm...> - 2012年02月28日 20:48:31
On Tue, Feb 28, 2012 at 12:45 PM, Federico Ariza
<ari...@gm...>wrote:
> Hello everybody
>
> This is my first post to the list.
>
Welcome.
>
> To the point.
> I want to access the all the axes located where a mouse event occurred.
>
> My first try is with button_release_event
> The event will include inaxes, so I know the axes where the mouse event
> occurred.
> This is fine if at that location I have only one axes.
>
> If I have a twinx or twiny I only get the axes with the biggest zorder.
>
> The example:
>
> import matplotlib.pyplot as plt
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(range(100),range(100))
> ax1 = ax.twinx()
> plt.show()
>
You can get all the x-axes shares with "ax1" (not including ax1) with the
following:
 sharedx = [ax for ax in ax1.get_shared_x_axes().get_siblings(ax1) if ax
is not ax1]
sharedx is a list of axes who share the x-axis with ax1
>
> The question
> Having either ax or ax1 is it possible to find the other?
> In other words, from a given axes instance, is it possible to know which
> other axes
> "share" the same xaxis or yaxis?
From: Russell E. O. <ro...@uw...> - 2012年02月28日 20:44:38
In article 
<CAC...@ma...>,
 William Jennings <wil...@gm...> 
 wrote:
> Hello mat plot lib users!
> I feel quite embarrassed that I've gone through 2 days of trying to get to
> get numpy, scipy and matplotlib all to work nice with each other. I've
> scraped through forums, stackoverflow and all the links that can bide me
> some type of logic. Yet, alas I still fail wildly with this set of errors:
> 
> *my current status is: just did a fresh install of my lion os and haven't
> installed Xcode yet. I'm a little lost and have found only macports,
> homebrew guides online only to be a slower failure. I really need to use
> this software but I'm finding it difficult keeping straight what order and
> what I need to install. 
I recommend:
- Install python.org 64-bit Python 2.7 (the one labelled as being for 
MacOS X 10.6 and later)
- Install numpy, scipy and matplotlib Mac binary with "macosx10.6" in 
their names. These are available from the web sites maintained by those 
projects.
Or if you want better backward compatibility (e.g. if you plan to 
distribute applications) then instead you should use the 32-bit 
python.org python (marked as for MacOS X 10.3 and later) and the numpy, 
scipy and matplotlib Mac binary installers with "macosx10.3" in their 
names.
-- Russell
From: Andreas H. <li...@hi...> - 2012年02月28日 19:41:37
Am Di 28 Feb 2012 19:23:14 CET schrieb Eric Firing:
> On 02/28/2012 08:08 AM, Andreas H. wrote:
>> Am 28.02.2012 18:56, schrieb Eric Firing:
>>> On 02/28/2012 06:28 AM, Andreas H. wrote:
>>>>>> On Tuesday, February 28, 2012, Andreas H. wrote:
>>>>>>
>>>>>>> Good morning,
>>>>>>>
>>>>>>> I'm creating the attached plot using pcolormesh(). What I would like to
>>>>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>>>>>>
>>>>>>> The problem is that when I use contour(), the lines drawn do not follow
>>>>>>> the grid edges but seem to be interpolated somehow.
>>>>>>>
>>>>>>> Do you have an idea how to draw the contour lines following the grid
>>>>>>> edges?
>>>>>>>
>>>>>>> Your insight is very much appreciated :)
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Andreas.
>>>>>>>
>>>>>>
>>>>>> This is because of a subtle difference in how pcolor-like functions and
>>>>>> contour-like functions work. I always forget which is which, but one
>>>>>> assumes that the z value lies on the vertices of the grid while the
>>>>>> other
>>>>>> assumes that it lies in the middle of each grid point. This is why you
>>>>>> see
>>>>>> them slightly offset from each other.
>>>>>
>>>>> Thanks, Ben!
>>>>>
>>>>> To `pcolormesh`, I pass the *edges* of the grid:
>>>>>
>>>>> xbin = linspace(0, 12, nxbin + 1)
>>>>> ybin = np.linspace(-90, 90, nybin + 1)
>>>>>
>>>>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None',
>>>>> vmin=-5, vmax=20)
>>>>>
>>>>> `contour`, however, wants the coordinates themselves. So I do
>>>>>
>>>>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T,
>>>>> [-2.5, 2.5])
>>>>>
>>>>> Still, the outcome is, well, unexpected to me. Actually, no matter if
>>>>> contour wants centres or edges, the actual behaviour seems strange. There
>>>>> is some interpolation going on, apparently. The input `pdata` has shape
>>>>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid
>>>>> movement in the x-direction.
>>>>>
>>>>> Any ideas?
>>>>
>>>> Okay, after some diving into matplotlib sources, I guess the interpolation
>>>> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So
>>>> there seems to be no way to accomplish what I actually want with the
>>>> current matplotlib API. Correct?
>>>>
>>>> If I wanted to do something about this, I would need to
>>>>
>>>> * implement a class `GriddedContourSet`, derived from `ContourSet`, where
>>>> I implement the `_get_allsegs_and_allkinds` method appropriately.
>>>> * add an additional keyword argument to `contour()` to make this gridded
>>>> contourset an option when calling `contour()`.
>>>>
>>>> Is this all correct? If yes, I might start working on this if I get the
>>>> time ...
>>>
>>> It is not at all clear to me what you want to do, as compared to what
>>> contour does. Can you illustrate with an extremely simple example?
>>> Maybe even a scanned sketch, if necessary? Do you want the contour lines
>>> to be stepped, like the rectilinear boundaries of the pcolormesh
>>> cells--that is, composed entirely of horizontal and vertical line segments?
>>
>> Yes, Eric, that's exactly what I want. Since my case was simple enough,
>> I did it completely manually, with loads of calls to `plot` (I'm sure
>> there would've been a simpler solution ... -- which one?). I attached
>> the plot so you get an idea of what I want to do.
>
> Andreas,
>
> I have never seen a contour algorithm with an option to do that, but I 
> understand the motivation. I don't think it would be easy to implement; 
> contouring algorithms generally are not.
>
> You might get an adequate approximation by using nearest-neighbor 
> interpolation to interpolate your data to a very fine grid, and then 
> contour that.
Eric,
thanks, that's a good hint. I took a look into the C source of the 
contour algorithm and decided not to bother right now. But your 
suggestion should do it.
Cheers,
Andreas.
From: Federico A. <ari...@gm...> - 2012年02月28日 18:46:07
Hello everybody
This is my first post to the list.
To the point.
I want to access the all the axes located where a mouse event occurred.
My first try is with button_release_event
The event will include inaxes, so I know the axes where the mouse event
occurred.
This is fine if at that location I have only one axes.
If I have a twinx or twiny I only get the axes with the biggest zorder.
The example:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(100),range(100))
ax1 = ax.twinx()
plt.show()
The question
Having either ax or ax1 is it possible to find the other?
In other words, from a given axes instance, is it possible to know which
other axes
"share" the same xaxis or yaxis?
Thanks
Federico
-- 
Y yo que culpa tengo de que ellas se crean todo lo que yo les digo?
-- Antonio Alducin --
From: Eric F. <ef...@ha...> - 2012年02月28日 18:24:58
On 02/28/2012 08:08 AM, Andreas H. wrote:
> Am 28.02.2012 18:56, schrieb Eric Firing:
>> On 02/28/2012 06:28 AM, Andreas H. wrote:
>>>>> On Tuesday, February 28, 2012, Andreas H. wrote:
>>>>>
>>>>>> Good morning,
>>>>>>
>>>>>> I'm creating the attached plot using pcolormesh(). What I would like to
>>>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>>>>>
>>>>>> The problem is that when I use contour(), the lines drawn do not follow
>>>>>> the grid edges but seem to be interpolated somehow.
>>>>>>
>>>>>> Do you have an idea how to draw the contour lines following the grid
>>>>>> edges?
>>>>>>
>>>>>> Your insight is very much appreciated :)
>>>>>>
>>>>>> Cheers,
>>>>>> Andreas.
>>>>>>
>>>>>
>>>>> This is because of a subtle difference in how pcolor-like functions and
>>>>> contour-like functions work. I always forget which is which, but one
>>>>> assumes that the z value lies on the vertices of the grid while the
>>>>> other
>>>>> assumes that it lies in the middle of each grid point. This is why you
>>>>> see
>>>>> them slightly offset from each other.
>>>>
>>>> Thanks, Ben!
>>>>
>>>> To `pcolormesh`, I pass the *edges* of the grid:
>>>>
>>>> xbin = linspace(0, 12, nxbin + 1)
>>>> ybin = np.linspace(-90, 90, nybin + 1)
>>>>
>>>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None',
>>>> vmin=-5, vmax=20)
>>>>
>>>> `contour`, however, wants the coordinates themselves. So I do
>>>>
>>>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T,
>>>> [-2.5, 2.5])
>>>>
>>>> Still, the outcome is, well, unexpected to me. Actually, no matter if
>>>> contour wants centres or edges, the actual behaviour seems strange. There
>>>> is some interpolation going on, apparently. The input `pdata` has shape
>>>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid
>>>> movement in the x-direction.
>>>>
>>>> Any ideas?
>>>
>>> Okay, after some diving into matplotlib sources, I guess the interpolation
>>> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So
>>> there seems to be no way to accomplish what I actually want with the
>>> current matplotlib API. Correct?
>>>
>>> If I wanted to do something about this, I would need to
>>>
>>> * implement a class `GriddedContourSet`, derived from `ContourSet`, where
>>> I implement the `_get_allsegs_and_allkinds` method appropriately.
>>> * add an additional keyword argument to `contour()` to make this gridded
>>> contourset an option when calling `contour()`.
>>>
>>> Is this all correct? If yes, I might start working on this if I get the
>>> time ...
>>
>> It is not at all clear to me what you want to do, as compared to what
>> contour does. Can you illustrate with an extremely simple example?
>> Maybe even a scanned sketch, if necessary? Do you want the contour lines
>> to be stepped, like the rectilinear boundaries of the pcolormesh
>> cells--that is, composed entirely of horizontal and vertical line segments?
>
> Yes, Eric, that's exactly what I want. Since my case was simple enough,
> I did it completely manually, with loads of calls to `plot` (I'm sure
> there would've been a simpler solution ... -- which one?). I attached
> the plot so you get an idea of what I want to do.
Andreas,
I have never seen a contour algorithm with an option to do that, but I 
understand the motivation. I don't think it would be easy to implement; 
contouring algorithms generally are not.
You might get an adequate approximation by using nearest-neighbor 
interpolation to interpolate your data to a very fine grid, and then 
contour that.
Eric
>
> Thanks for your help!
> Andreas.
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Andreas H. <li...@hi...> - 2012年02月28日 18:08:36
Attachments: example.pdf
Am 28.02.2012 18:56, schrieb Eric Firing:
> On 02/28/2012 06:28 AM, Andreas H. wrote:
>>>> On Tuesday, February 28, 2012, Andreas H. wrote:
>>>>
>>>>> Good morning,
>>>>>
>>>>> I'm creating the attached plot using pcolormesh(). What I would like to
>>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>>>>
>>>>> The problem is that when I use contour(), the lines drawn do not follow
>>>>> the grid edges but seem to be interpolated somehow.
>>>>>
>>>>> Do you have an idea how to draw the contour lines following the grid
>>>>> edges?
>>>>>
>>>>> Your insight is very much appreciated :)
>>>>>
>>>>> Cheers,
>>>>> Andreas.
>>>>>
>>>>
>>>> This is because of a subtle difference in how pcolor-like functions and
>>>> contour-like functions work. I always forget which is which, but one
>>>> assumes that the z value lies on the vertices of the grid while the
>>>> other
>>>> assumes that it lies in the middle of each grid point. This is why you
>>>> see
>>>> them slightly offset from each other.
>>>
>>> Thanks, Ben!
>>>
>>> To `pcolormesh`, I pass the *edges* of the grid:
>>>
>>> xbin = linspace(0, 12, nxbin + 1)
>>> ybin = np.linspace(-90, 90, nybin + 1)
>>>
>>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None',
>>> vmin=-5, vmax=20)
>>>
>>> `contour`, however, wants the coordinates themselves. So I do
>>>
>>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T,
>>> [-2.5, 2.5])
>>>
>>> Still, the outcome is, well, unexpected to me. Actually, no matter if
>>> contour wants centres or edges, the actual behaviour seems strange. There
>>> is some interpolation going on, apparently. The input `pdata` has shape
>>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid
>>> movement in the x-direction.
>>>
>>> Any ideas?
>>
>> Okay, after some diving into matplotlib sources, I guess the interpolation
>> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So
>> there seems to be no way to accomplish what I actually want with the
>> current matplotlib API. Correct?
>>
>> If I wanted to do something about this, I would need to
>>
>> * implement a class `GriddedContourSet`, derived from `ContourSet`, where
>> I implement the `_get_allsegs_and_allkinds` method appropriately.
>> * add an additional keyword argument to `contour()` to make this gridded
>> contourset an option when calling `contour()`.
>>
>> Is this all correct? If yes, I might start working on this if I get the
>> time ...
> 
> It is not at all clear to me what you want to do, as compared to what 
> contour does. Can you illustrate with an extremely simple example? 
> Maybe even a scanned sketch, if necessary? Do you want the contour lines 
> to be stepped, like the rectilinear boundaries of the pcolormesh 
> cells--that is, composed entirely of horizontal and vertical line segments?
Yes, Eric, that's exactly what I want. Since my case was simple enough,
I did it completely manually, with loads of calls to `plot` (I'm sure
there would've been a simpler solution ... -- which one?). I attached
the plot so you get an idea of what I want to do.
Thanks for your help!
Andreas.
From: Eric F. <ef...@ha...> - 2012年02月28日 17:57:07
On 02/28/2012 06:28 AM, Andreas H. wrote:
>>> On Tuesday, February 28, 2012, Andreas H. wrote:
>>>
>>>> Good morning,
>>>>
>>>> I'm creating the attached plot using pcolormesh(). What I would like to
>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>>>
>>>> The problem is that when I use contour(), the lines drawn do not follow
>>>> the grid edges but seem to be interpolated somehow.
>>>>
>>>> Do you have an idea how to draw the contour lines following the grid
>>>> edges?
>>>>
>>>> Your insight is very much appreciated :)
>>>>
>>>> Cheers,
>>>> Andreas.
>>>>
>>>
>>> This is because of a subtle difference in how pcolor-like functions and
>>> contour-like functions work. I always forget which is which, but one
>>> assumes that the z value lies on the vertices of the grid while the
>>> other
>>> assumes that it lies in the middle of each grid point. This is why you
>>> see
>>> them slightly offset from each other.
>>
>> Thanks, Ben!
>>
>> To `pcolormesh`, I pass the *edges* of the grid:
>>
>> xbin = linspace(0, 12, nxbin + 1)
>> ybin = np.linspace(-90, 90, nybin + 1)
>>
>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None',
>> vmin=-5, vmax=20)
>>
>> `contour`, however, wants the coordinates themselves. So I do
>>
>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T,
>> [-2.5, 2.5])
>>
>> Still, the outcome is, well, unexpected to me. Actually, no matter if
>> contour wants centres or edges, the actual behaviour seems strange. There
>> is some interpolation going on, apparently. The input `pdata` has shape
>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid
>> movement in the x-direction.
>>
>> Any ideas?
>
> Okay, after some diving into matplotlib sources, I guess the interpolation
> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So
> there seems to be no way to accomplish what I actually want with the
> current matplotlib API. Correct?
>
> If I wanted to do something about this, I would need to
>
> * implement a class `GriddedContourSet`, derived from `ContourSet`, where
> I implement the `_get_allsegs_and_allkinds` method appropriately.
> * add an additional keyword argument to `contour()` to make this gridded
> contourset an option when calling `contour()`.
>
> Is this all correct? If yes, I might start working on this if I get the
> time ...
It is not at all clear to me what you want to do, as compared to what 
contour does. Can you illustrate with an extremely simple example? 
Maybe even a scanned sketch, if necessary? Do you want the contour lines 
to be stepped, like the rectilinear boundaries of the pcolormesh 
cells--that is, composed entirely of horizontal and vertical line segments?
Eric
>
> Cheers,
> Andreas.
>
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Dave E. <d.e...@la...> - 2012年02月28日 16:58:23
Hello --
When I run the following code (heavily adapted from the matplotlib examples):
...
SCHistogram = Figure(figsize=(6,6), dpi=300, facecolor='w') # 6 inches across (X-axis) by 4 inches tall (Y-axis)
ax = SCHistogram.add_subplot(111)
canvas = FigureCanvas(SCHistogram)
AxisTitleFontProps = FontProperties(size=10, family='serif')
AxisTitleFontProps.set_name('Times')
n, bins, patches = ax.hist(DimensionData)
y = normpdf( bins, self.meanVal, self.stdDev)
line, = ax.plot(bins, y, 'r--')
line.set_linewidth(1)
ax.set_xlabel(self.Description, fontproperties=AxisTitleFontProps)
ax.set_ylabel('Number of Parts' ,fontproperties=AxisTitleFontProps)
ax.set_xlim([x_lowest, x_highest])
ax.plot([self.LCL,self.LCL],[0,max(n)],'b--')
ax.plot([self.Nom,self.Nom],[0,max(n)],'g--')
ax.plot([self.UCL,self.UCL],[0,max(n)],'r--')
.
.
.
AxisTickFontProps = copy.deepcopy(AxisTitleFontProps)
AxisTickFontProps.set_size(7)
canvas.draw()
s = canvas.tostring_rgb() # save this and convert to bitmap as needed
The following error appears when run under matplotlib 1.1 (the code successfully completes in v1.0.1):
Traceback (most recent call last):
 File "./analyze.pyw", line 681, in fileGenerateReport
 SPC_PDF.Generate()
 File "/Users/engelsma/dev/SPC_Analyzer/trunk/1.0.10/report.py", line 201, in Generate
 eachSC.CreateHistogram(eachSC.TempImgFile)
 File "/Users/engelsma/dev/SPC_Analyzer/trunk/1.0.10/SPCmodules.py", line 318, in CreateHistogram
 s = canvas.tostring_rgb() # save this and convert to bitmap as needed
 File "/Users/engelsma/.virtualenvs/cmm/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 418, in tostring_rgb
 return self.renderer.tostring_rgb()
AttributeError: 'FigureCanvasQTAgg' object has no attribute 'renderer'
Any ideas as to why this code fails under v1.1? I've checked the changelog and I see nothing that would cause this problem... 
Thanks in advance, 
Dave Engelsma
From: Andreas H. <li...@hi...> - 2012年02月28日 16:28:56
>> On Tuesday, February 28, 2012, Andreas H. wrote:
>>
>>> Good morning,
>>>
>>> I'm creating the attached plot using pcolormesh(). What I would like to
>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>>
>>> The problem is that when I use contour(), the lines drawn do not follow
>>> the grid edges but seem to be interpolated somehow.
>>>
>>> Do you have an idea how to draw the contour lines following the grid
>>> edges?
>>>
>>> Your insight is very much appreciated :)
>>>
>>> Cheers,
>>> Andreas.
>>>
>>
>> This is because of a subtle difference in how pcolor-like functions and
>> contour-like functions work. I always forget which is which, but one
>> assumes that the z value lies on the vertices of the grid while the
>> other
>> assumes that it lies in the middle of each grid point. This is why you
>> see
>> them slightly offset from each other.
>
> Thanks, Ben!
>
> To `pcolormesh`, I pass the *edges* of the grid:
>
> xbin = linspace(0, 12, nxbin + 1)
> ybin = np.linspace(-90, 90, nybin + 1)
>
> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None',
> vmin=-5, vmax=20)
>
> `contour`, however, wants the coordinates themselves. So I do
>
> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T,
> [-2.5, 2.5])
>
> Still, the outcome is, well, unexpected to me. Actually, no matter if
> contour wants centres or edges, the actual behaviour seems strange. There
> is some interpolation going on, apparently. The input `pdata` has shape
> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid
> movement in the x-direction.
>
> Any ideas?
Okay, after some diving into matplotlib sources, I guess the interpolation
comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So
there seems to be no way to accomplish what I actually want with the
current matplotlib API. Correct?
If I wanted to do something about this, I would need to
* implement a class `GriddedContourSet`, derived from `ContourSet`, where
I implement the `_get_allsegs_and_allkinds` method appropriately.
* add an additional keyword argument to `contour()` to make this gridded
contourset an option when calling `contour()`.
Is this all correct? If yes, I might start working on this if I get the
time ...
Cheers,
Andreas.
From: Andreas H. <li...@hi...> - 2012年02月28日 15:22:26
> On Tuesday, February 28, 2012, Andreas H. wrote:
>
>> Good morning,
>>
>> I'm creating the attached plot using pcolormesh(). What I would like to
>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>
>> The problem is that when I use contour(), the lines drawn do not follow
>> the grid edges but seem to be interpolated somehow.
>>
>> Do you have an idea how to draw the contour lines following the grid
>> edges?
>>
>> Your insight is very much appreciated :)
>>
>> Cheers,
>> Andreas.
>>
>
> This is because of a subtle difference in how pcolor-like functions and
> contour-like functions work. I always forget which is which, but one
> assumes that the z value lies on the vertices of the grid while the other
> assumes that it lies in the middle of each grid point. This is why you
> see
> them slightly offset from each other.
Thanks, Ben!
To `pcolormesh`, I pass the *edges* of the grid:
 xbin = linspace(0, 12, nxbin + 1)
 ybin = np.linspace(-90, 90, nybin + 1)
 pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None',
 vmin=-5, vmax=20)
`contour`, however, wants the coordinates themselves. So I do
 spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T,
[-2.5, 2.5])
Still, the outcome is, well, unexpected to me. Actually, no matter if
contour wants centres or edges, the actual behaviour seems strange. There
is some interpolation going on, apparently. The input `pdata` has shape
(12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid
movement in the x-direction.
Any ideas?
Cheers,
Andreas.
From: Ryan M. <rm...@gm...> - 2012年02月28日 15:20:12
On Tue, Feb 28, 2012 at 9:10 AM, Benjamin Root <ben...@ou...> wrote:
> On Tuesday, February 28, 2012, Andreas H. wrote:
>>
>> Good morning,
>>
>> I'm creating the attached plot using pcolormesh(). What I would like to
>> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>>
>> The problem is that when I use contour(), the lines drawn do not follow
>> the grid edges but seem to be interpolated somehow.
>>
>> Do you have an idea how to draw the contour lines following the grid
>> edges?
>>
>> Your insight is very much appreciated :)
>>
>> Cheers,
>> Andreas.
>
>
> This is because of a subtle difference in how pcolor-like functions and
> contour-like functions work. I always forget which is which, but one
> assumes that the z value lies on the vertices of the grid while the other
> assumes that it lies in the middle of each grid point. This is why you see
> them slightly offset from each other.
By definitition, with pcolormesh you're giving it the edges of the
grid cells. In fact, for an NxN grid of data, you should have N+1xN+1
grids of x,y values. Contour is given the actual grid and values.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Benjamin R. <ben...@ou...> - 2012年02月28日 15:11:06
On Tuesday, February 28, 2012, Andreas H. wrote:
> Good morning,
>
> I'm creating the attached plot using pcolormesh(). What I would like to
> do now is draw contour lines at +/- 2.5%, which follow the grid edges.
>
> The problem is that when I use contour(), the lines drawn do not follow
> the grid edges but seem to be interpolated somehow.
>
> Do you have an idea how to draw the contour lines following the grid edges?
>
> Your insight is very much appreciated :)
>
> Cheers,
> Andreas.
>
This is because of a subtle difference in how pcolor-like functions and
contour-like functions work. I always forget which is which, but one
assumes that the z value lies on the vertices of the grid while the other
assumes that it lies in the middle of each grid point. This is why you see
them slightly offset from each other.
I hope that clarifies everything for you.
Ben Root
From: Andreas H. <li...@hi...> - 2012年02月28日 09:42:27
Good morning,
I'm creating the attached plot using pcolormesh(). What I would like to
do now is draw contour lines at +/- 2.5%, which follow the grid edges.
The problem is that when I use contour(), the lines drawn do not follow
the grid edges but seem to be interpolated somehow.
Do you have an idea how to draw the contour lines following the grid edges?
Your insight is very much appreciated :)
Cheers,
Andreas.

Showing 19 results of 19

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