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

Showing 5 results of 5

From: jan_strube <cur...@gm...> - 2009年07月18日 09:51:50
Hi Jouni,
Jouni K. Seppänen wrote:
> 
> jan_strube <cur...@gm...> writes:
> 
> Do you mean that saving as pdf from the qt4agg backend causes the same
> error, or is there a different error raised from that particular
> backend? When you save as pdf, you (usually) invoke the pdf backend, no
> matter what interactive backend you use.
> 
Yes, same error.
> Thank you for the report and the example! I think I have fixed this for
> the svg and pdf backends, but the PostScript backend still needs work.
> 
The pdf example seems to somewhat work, both on mac os x and on linux. The
hatch lines are really faint, but I can probably play with the matplotlibrc
settings to fix that.
The svg works on linux, but not quite on mac osx.
Safari complains:
This page contains the following errors:
error on line 354 at column 2372: Extra content at the end of the document
Below is a rendering of the page up to the first error.
Thanks for the fix.
Cheers,
 Jan
-- 
Jouni K. Seppänen
http://www.iki.fi/jks
-- 
View this message in context: http://www.nabble.com/plotting-problems-in-qt4agg-backend-on-Mac-OS-X-tp24499919p24546274.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John [H2O] <was...@gm...> - 2009年07月18日 09:28:08
Below is what I am trying to do, perhaps I am doing something wrong
somewhere?
John Hunter-4 wrote:
> 
> 
> or explicitly reuse the same fig by giving a figure number and clearing
> it:
> 
> for i in range(1000):
> fig = plt.figure(1)
> # plot something
> fig.cla()
> 
> JDH
> 
My Program is below. NOTE: The kwargs bit is before I realized how much
easier it is just to assign defaults in the definition... (haven't changed
it yet). 
The main thing I am using is FIGURE, which is a list containing the figure,
basemap instance, and the axes. I 'pass' these around trying to reuse them
as you show above.
In the main loop of the program I pass the FIGURE list to three calls to
plot_track. I try to reuse all the instances (I found creating the basemap
instance to be very slow). At the end of each loop in the mainloop I call:
FIGURE[2].cla() 
Which I understand to clear the axes. Maybe I should also be calling:
FIGURE[0].cla()
??
Thank you in advance!
def plot_track(lon,lat,**kwargs):
 """ Plot an longitude,latitude course over a basemap """
 if 'region' in kwargs.keys():
 region = kwargs['region']
 else:
 region = 1
 if 'figname' in kwargs.keys():
 figname = kwargs['figname']
 else:
 figname = None
 if 'FIGURE' in kwargs.keys():
 FIGURE = kwargs['FIGURE']
 else:
 FIGURE = [None,None,None]
 if 'overlay' in kwargs.keys():
 overlay = kwargs['overlay']
 else:
 overlay = 0
 if 'zlevel' in kwargs.keys():
 zlevel = kwargs['zlevel']
 else:
 zlevel = None
 if 'zsize' in kwargs.keys():
 zsize = kwargs['zsize']
 else:
 zsize = np.ones(len(lon))
 if 'base' in kwargs.keys():
 base = kwargs['base']
 else:
 base = 1
 
 ## Extract plotting kwargs, just makes a dict I can pass to basemap plot
command
 plot_kwargs = set_plotkwargs(kwargs)
 
 ##Get fig if exists
 fig=FIGURE[0]
 m=FIGURE[1]
 az=FIGURE[2]
 nullfmt = NullFormatter()
 if fig==None:
 # get a basemap from Basemap passing the region info. 
 exec("fig,m=get_base%s(region=region,coords=(lon,lat))"%base)
 if az==None: 
 ax=plt.gca()
 pos = ax.get_position()
 l, b, w, h = getattr(pos, 'bounds', pos)
 az = fig.add_axes([l,b,w,h],frameon=False)
 if az!=None and overlay==0:
 az.cla()
 plt.axes(az)
 #PRINT TRACK
 cx,cy = m(lon,lat)
 if zlevel!=None: 
 
c=m.scatter(cx,cy,zsize,zlevel,cmap=cm.spectral,marker=marker,faceted=False,zorder=10,alpha=0.35) 
 #m.scatter has no color bar, so create a ghost 'scatter' instance:
 ax=plt.gca()
 plt.draw()
 pos = ax.get_position()
 l, b, w, h = getattr(pos, 'bounds', pos)
 jnkax = fig.add_axes([l,b,w,h],frameon=False)
 axes(jnkax)
 plt.figure(); 
 
plt.scatter(cx,cy,zsize,zlevel,cmap=cm.spectral,marker=marker,faceted=False,zorder=10,alpha=0.75)
 plt.figure(fig.number);
 cax = plt.axes([l+w+0.03, b, 0.02, h]) 
 plt.colorbar(cax=cax) # draw colorbar
 #delete the ghost instance
 plt.close(2); 
 #make the ax axes active
 plt.axes(ax);
 else:
 m.plot(cx,cy,**plot_kwargs)
 plt.axes(az)
 az.xaxis.set_major_formatter( nullfmt )
 az.yaxis.set_major_formatter( nullfmt )
 plt.setp(az, xticks=[],yticks=[])
 az.axesPatch.set_alpha(0.0)
 if figname:
 savefig(figname)
 FIGURE=[fig,m,az] 
 return FIGURE
-- 
View this message in context: http://www.nabble.com/plotting-100%27s-of-figures%2C-mpl-slows-and-consumes-memory%21-tp24543343p24546109.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jouni K. S. <jk...@ik...> - 2009年07月18日 08:38:28
jan_strube <cur...@gm...> writes:
> File
> "/home/jstrube/local//lib64/python2.6/site-packages/matplotlib/backends/backend_pdf.py",
> line 1723, in _fillp
> (len(self._fillcolor) <= 3 or self._fillcolor[3] != 0.0))
> TypeError: object of type 'NoneType' has no len()
Yes, that looks like a bug. It seems that the hatch support doesn't get
a lot of use, so you have run into an edge case that no-one has
encountered before.
> This is the case not only for the pdf backend, but for the qt4agg backend as
> well.
Do you mean that saving as pdf from the qt4agg backend causes the same
error, or is there a different error raised from that particular
backend? When you save as pdf, you (usually) invoke the pdf backend, no
matter what interactive backend you use.
> Yes, the example works just fine. I am attaching a self-contained example to
> reproduce the problem.
Thank you for the report and the example! I think I have fixed this for
the svg and pdf backends, but the PostScript backend still needs work.
-- 
Jouni K. Seppänen
http://www.iki.fi/jks
From: John H. <jd...@gm...> - 2009年07月18日 00:55:34
On Fri, Jul 17, 2009 at 7:02 PM, John [H2O]<was...@gm...> wrote:
>
> I have a script looping through and plotting 100's of figures. It runs fine,
> but after the first few plots, the loop considerably slows down and the
> memory usage keeps going up.
>
> The script is quite complicated, so can't really paste it here, but I am
> trying to pass figure instances around and I am trying to reuse the
> axes/figures... but maybe someone could demonstrate how this is done
> efficiently?
You either need to close the figure in the loop, or reuse the same
figure and cla it, eg
for i in range(1000):
 fig = plt.figure()
 # plot something
 plt.close(fig)
or explicitly reuse the same fig by giving a figure number and clearing it:
for i in range(1000):
 fig = plt.figure(1)
 # plot something
 fig.cla()
JDH
From: John [H2O] <was...@gm...> - 2009年07月18日 00:02:38
I have a script looping through and plotting 100's of figures. It runs fine,
but after the first few plots, the loop considerably slows down and the
memory usage keeps going up. 
The script is quite complicated, so can't really paste it here, but I am
trying to pass figure instances around and I am trying to reuse the
axes/figures... but maybe someone could demonstrate how this is done
efficiently?
What do I need to do so that each successive plot is using the same instance
of axes rather than adding a new one... this is all I can imagine is
happening.
Thanks,
john
-- 
View this message in context: http://www.nabble.com/plotting-100%27s-of-figures%2C-mpl-slows-and-consumes-memory%21-tp24543343p24543343.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Showing 5 results of 5

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