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

Showing 12 results of 12

From: Matt E. <ma...@ea...> - 2011年09月09日 22:04:56
Hi all,
I am encountering a memory leak type issue when running the following,
for example.
http://codepad.org/TNuCLT3k
Matplotlib version: 0.99.3
PyQt4 Version: 4.8.5
I found a thread in the archive relating to this issue which supposedly
disappeared upon updating to PyQt 4.8.4 (I trust it would not have been
reintroduced in going to .5).
Can someone confirm or deny replication of this issue with their setup
and/or offer a solution?
Thanks very much
Matt Earnshaw
From: Gökhan S. <gok...@gm...> - 2011年09月09日 21:15:05
Hi,
The code below should create a properly placed 2nd x-axis. You might need to
adjust the placement of the figure canvas to match into the window.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
fig = plt.figure(figsize=(10,8))
host = SubplotHost(fig, 111)
fig.add_subplot(host)
parx = host.twiny()
parx.axis["top"].set_visible(False)
offset = 0, -50
new_axisline = parx.get_grid_helper().new_fixed_axis
parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
parx.axis["bottom"].label.set_visible(True)
hplt, = host.plot(np.random.rand(100))
p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0,
color='green')
plt.show()
There is also another example at:
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisartist-with-parasiteaxes
Hope this helps.
On Fri, Sep 9, 2011 at 12:50 PM, Neal Becker <ndb...@gm...> wrote:
> Neal Becker wrote:
>
> > I have a semilog plot. I'd like to add a second x axis (maybe below the
> > existing one, or else maybe on top of graph). This second x axis is
> simply
> > describing the same existing data, in different units.
> >
> > For example imagine a plot of
> >
> > x - time in seconds
> > y - velocity
> >
> > x2 - time in minutes
> >
> >
>
> This almost works:
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ...
> ax2 = ax.twiny()
> min_x, max_x = ax.get_xlim()
> ax2.set_xlim (min_x-1, max_x-1)
>
> except the 2nd x axis is on the top, and prints right on top of the title
>
>
>
> ------------------------------------------------------------------------------
> Why Cloud-Based Security and Archiving Make Sense
> Osterman Research conducted this study that outlines how and why cloud
> computing security and archiving is rapidly being adopted across the IT
> space for its ease of implementation, lower cost, and increased
> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Gökhan
From: Neal B. <ndb...@gm...> - 2011年09月09日 18:50:38
Neal Becker wrote:
> I have a semilog plot. I'd like to add a second x axis (maybe below the
> existing one, or else maybe on top of graph). This second x axis is simply
> describing the same existing data, in different units.
> 
> For example imagine a plot of
> 
> x - time in seconds
> y - velocity
> 
> x2 - time in minutes
> 
> 
This almost works:
 fig = plt.figure() 
 ax = fig.add_subplot(111) 
...
 ax2 = ax.twiny()
 min_x, max_x = ax.get_xlim()
 ax2.set_xlim (min_x-1, max_x-1)
except the 2nd x axis is on the top, and prints right on top of the title
From: Paul H. <pmh...@gm...> - 2011年09月09日 18:36:01
Ben and Yves,
Might this be behavior defined in the matplotlibrc file?
In [21]: import matplotlib as mpl
In [22]: mpl.rcParams['figure.edgecolor']
Out[22]: 'w'
-paul
On Fri, Sep 9, 2011 at 9:37 AM, Benjamin Root <ben...@ou...> wrote:
> On Fri, Sep 9, 2011 at 3:49 AM, Yves Revaz <yve...@ep...> wrote:
>>
>> On 09/08/2011 06:09 PM, Benjamin Root wrote:
>>
>> On Thu, Sep 8, 2011 at 10:30 AM, Yves Revaz <yve...@ep...> wrote:
>>>
>>> Dear List,
>>>
>>> when I'm saving a plot with the option facecolor='k',
>>> around my image, there is still a one pixel white border.
>>>
>>> How is it possible to remove this ?
>>>
>>> try for example this very simple script:
>>> (using )
>>>
>>> import pylab as pt
>>> from numpy import *
>>>
>>> x = arange(0,10)
>>> y = x**2
>>> pt.plot(x,y)
>>>
>>> pt.savefig('qq.png',facecolor='k')
>>>
>>>
>>> Thanks in advance.
>>>
>>> yves
>>>
>>
>> yves,
>>
>> This might depend on the version of matplotlib and which backend you are
>> using. I currently do not see this white line on my development build of
>> mpl using the GTKAgg backend. What are you using?
>>
>>
>> Hi Ben,
>>
>> Thanks for you reply.
>>
>> I'm using :
>>
>> >>> import matplotlib
>> >>> matplotlib.__version__
>> '1.0rc1'
>
> That version is over a year old. Since then, I know that some "off-by-one"
> pixel bugs have been fixed.
>
>>
>> with the GTKAgg backend.
>> I join a zoom of a corner of the image to show that
>> there is one white line and a second gray one.
>>
>> I tried different backend, with some of them (XV, GTKCairo),
>> the white line disapears but in all cases, the gray line is present :-( .
>>
>> Do you really have nothing like that ?
>>
>
> No, not in the latest development version, but I haven't checked for a gray
> line. Then again, that may be dependent upon the graphics viewer.
>
> You could try installing v1.0.1 now, or wait a bit for the upcoming v1.1
> release.
>
> I hope this helps!
> Ben Root
>
>
> ------------------------------------------------------------------------------
> Why Cloud-Based Security and Archiving Make Sense
> Osterman Research conducted this study that outlines how and why cloud
> computing security and archiving is rapidly being adopted across the IT
> space for its ease of implementation, lower cost, and increased
> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Daniel H. <dh...@gm...> - 2011年09月09日 18:18:59
Attachments: hitlist_problem.py
[resend: apologies for the html mail].
I was trying to implement something where the user could change the
properties of an artist by right clicking on it...so I needed to find
out what artists are under the cursor at the time of the click. It is
possible that the method that I'm using isn't the recommended one; if
not, I would appreciate any suggestions.
 I'm using fig.hitlist() to get the list of artists. This function
works just fine with a regular xy plot, but if one (or both) of the
axes are in log scale, I get a NotImplementedError exception and
associated stack trace (run the attached demo code to see). The
exception is being caused by line 249 in artists.py.
Now, if I modify artists.py slightly to swallow the exception, replacing
 for a in self.get_children():
   L.extend(a.hitlist(event))
 with
 try:
 for a in self.get_children():
   L.extend(a.hitlist(event))
 except:
  pass
 Then everything seems to work. However, being unfamiliar with the
code, I'm not sure what else that might break, or how bad of an idea
swallowing the exception is here.
 I have attached a small demo code. The error occurs in matplotlib
1.0.0 and matplotlib 1.0.1, on both Linux and Windows.
--
Daniel Hyams
dh...@gm...
From: Neal B. <ndb...@gm...> - 2011年09月09日 17:37:28
I have a semilog plot. I'd like to add a second x axis (maybe below the 
existing one, or else maybe on top of graph). This second x axis is simply 
describing the same existing data, in different units.
For example imagine a plot of
x - time in seconds
y - velocity
x2 - time in minutes
From: Benjamin R. <ben...@ou...> - 2011年09月09日 16:38:06
On Fri, Sep 9, 2011 at 3:49 AM, Yves Revaz <yve...@ep...> wrote:
> **
> On 09/08/2011 06:09 PM, Benjamin Root wrote:
>
> On Thu, Sep 8, 2011 at 10:30 AM, Yves Revaz <yve...@ep...> wrote:
>
>> Dear List,
>>
>> when I'm saving a plot with the option facecolor='k',
>> around my image, there is still a one pixel white border.
>>
>> How is it possible to remove this ?
>>
>> try for example this very simple script:
>> (using )
>>
>> import pylab as pt
>> from numpy import *
>>
>> x = arange(0,10)
>> y = x**2
>> pt.plot(x,y)
>>
>> pt.savefig('qq.png',facecolor='k')
>>
>>
>> Thanks in advance.
>>
>> yves
>>
>>
> yves,
>
> This might depend on the version of matplotlib and which backend you are
> using. I currently do not see this white line on my development build of
> mpl using the GTKAgg backend. What are you using?
>
>
> Hi Ben,
>
> Thanks for you reply.
>
> I'm using :
>
> >>> import matplotlib
> >>> matplotlib.__version__
> '1.0rc1'
>
That version is over a year old. Since then, I know that some "off-by-one"
pixel bugs have been fixed.
>
> with the GTKAgg backend.
> I join a zoom of a corner of the image to show that
> there is one white line and a second gray one.
>
> I tried different backend, with some of them (XV, GTKCairo),
> the white line disapears but in all cases, the gray line is present :-( .
>
> Do you really have nothing like that ?
>
>
No, not in the latest development version, but I haven't checked for a gray
line. Then again, that may be dependent upon the graphics viewer.
You could try installing v1.0.1 now, or wait a bit for the upcoming v1.1
release.
I hope this helps!
Ben Root
On 9/9/2011 6:42 AM, Scott Sinclair wrote:
> On 8 September 2011 19:20, Matt Funk <mat...@gm...> wrote:
>> Hi,
>> sorry that it has taken me so long to reply. Anyway, i could be wrong, but i
>> don't think that the code:
>> xi = np.linspace(llcrnlon,urcrnlon,1000)
>> yi = np.linspace(llcrnlat,urcrnlat,1000)
>>
>> will produce a grid which gives the lat/lon coordinates with 1km spacing.
>> The reason being is that the distance between 2 lons (say -117.731659 and
>> -91.303642) is different depending on where you are in terms of the latitude
>> (i.e. the extreme examples are of course the north pole vs the equator). So
>> the above gives a regular grid in terms of degrees but not in terms of
>> distance.
> Yes, that's correct. You'll need to project your original data
> locations into a cartesian co-ordinate system before interpolating
> their values onto a regular grid in that co-ordinate system using
> griddata et al.
>
> You might like to use pyproj (included with the basemap toolkit) to
> help you project from lat/lon to your chosen co-ordinate system..
I have been using gdal for many of my geographic needs. Is there an
advantage/disadvantage using pyproj vs capabilities found in gdal (from
what i understand both are based on PROJ.4)? Can you comment on this?
Also, i was thinking of projecting things to UTM for interpolation
purposes. Is there any apparent reason this is a bad idea vs a different
projected coordinate system?
matt
>
> Cheers,
> Scott
>
> ------------------------------------------------------------------------------
> Why Cloud-Based Security and Archiving Make Sense
> Osterman Research conducted this study that outlines how and why cloud
> computing security and archiving is rapidly being adopted across the IT 
> space for its ease of implementation, lower cost, and increased 
> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
Matt Funk
Research Associate
Plant and Environmental Scienc. Dept.
New Mexico State University
On 8 September 2011 19:20, Matt Funk <mat...@gm...> wrote:
> Hi,
> sorry that it has taken me so long to reply. Anyway, i could be wrong, but i
> don't think that the code:
>   xi = np.linspace(llcrnlon,urcrnlon,1000)
>   yi = np.linspace(llcrnlat,urcrnlat,1000)
>
> will produce a grid which gives the lat/lon coordinates with 1km spacing.
> The reason being is that the distance between 2 lons (say -117.731659 and
> -91.303642) is different depending on where you are in terms of the latitude
> (i.e. the extreme examples are of course the north pole vs the equator). So
> the above gives a regular grid in terms of degrees but not in terms of
> distance.
Yes, that's correct. You'll need to project your original data
locations into a cartesian co-ordinate system before interpolating
their values onto a regular grid in that co-ordinate system using
griddata et al.
You might like to use pyproj (included with the basemap toolkit) to
help you project from lat/lon to your chosen co-ordinate system..
Cheers,
Scott
From: Jakob M. <jak...@gm...> - 2011年09月09日 10:49:28
2011年9月8日 Jeff Whitaker <js...@fa...>:
> On 9/8/11 1:51 AM, Jakob Malm wrote:
>>
>> Picking up on an old thread. Hopefully Jeff is still listening in...
>>
>> On 2010年04月04日 23:24, Jeff Whitaker wrote:
>>>
>>> On 4/4/10 11:06 AM, Will Hewson wrote:
>>>>
>>>> Hi again Jeff et al...
>>>>
>>>> I've had a play around with the extra few lines of code - on paper this
>>>> seems like it should solve the problems I'm experiencing. However, an
>>>> error's being thrown up by the transform scalar function, as my lons and
>>>> lats won't necessarily be increasing. The data I'm plotting is satellite
>>>> data and so at the beginning and end of the orbit file lats go over the
>>>> pole
>>>> from 90 to -90, with a similar problem for the lons - whereby the data
>>>> is
>>>> taken across the satellite track. I've thought about sorting the data
>>>> before
>>>> passing it to transform_scalar but I'm always going to be left with the
>>>> problem in either lats or lons.
>>>>
>>>> I've uploaded the file I'm currently working with this time. It's three
>>>> columns of lons, lats and z values.
>>>>
>>>> Once again, many thanks for your help.
>>>>
>>>> Will.
>>>>
>>>> http://old.nabble.com/file/p28133659/test.plt test.plt
>>>>
>>> Will: Is it a regular lat/lon grid or a satellite swath? If it's the
>>> latter, you can't use my solution.
>>>
>>> -Jeff
>>
>> What if it _is_ a satellite swath? Can I get around the problem of
>> off-projection plotting with Basemap.pcolormesh()?
>> Example code and plots can be found at
>>
>> http://pythonbits.blogspot.com/2011/09/i-have-problem-with-basemap-plotting.html
>>
>> Thanks,
>> Jakob Malm
>>
>
>
> Jakob: I think that's the price you pay for the speed of pcolormesh (vs
> pcolor). It appears to make more assumptions about the structure of your
> data. I don't see any way around it.
>
> -Jeff
>
Hmm... I believe I have been able to get around it previously, but
perhaps I just fell back to using pcolor...
Thanks,
Jakob
From: Jeffrey S. <jef...@gm...> - 2011年09月09日 07:35:46
import matplotlib.ticker as tick
def showOnlySomeTicks(x, pos):
 s = str(int(x))
 if x == 5000:
 return '5e3'#'%.0e' % x
 return ''
ax = plt.axes([0.165,0.2,0.95-0.24,0.95-0.2])
ax.xaxis.set_minor_formatter(tick.FuncFormatter(showOnlySomeTicks))
Then in the code something just change xaxis to yaxis or vice versa. Can 
also set the major formatter like this. Not sure if this is what you 
were looking for but it seems you want custom tick labels. Can also set 
the location of the ticks and check ticker page below for more info.
For setting a different base check the multiplelocater from the ticker 
class here:
http://matplotlib.sourceforge.net/api/ticker_api.html
On 09/07/2011 08:03 PM, shaunh1 wrote:
> Hi,
>
> As the subject shows, I am trying to create a custom ticker (class??) that
> has pretty formatted log tick.
>
> Instead of just 10^-5, 10^-5, etc, is something more like
> [1-10^-2, 1-10^-3, 1-10^-4] etc
>
> I am histogram'n a set of data that is very close to 1, basically ranging
> from 0.990 and 0.9922, but mostly being centered on 0.9921. I would love to
> see meaningful labels.
>
> Any ideas?
From: Adam D. <ada...@gm...> - 2011年09月09日 06:27:12
Is there a way to reduce the lineweight of the axes frame edge?
Alternatively, is there a way to hide the edge of the frame without turning
the frame off?
Thanks,
Adam
2 messages has been excluded from this view by a project administrator.

Showing 12 results of 12

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