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

Showing results of 141

1 2 3 .. 6 > >> (Page 1 of 6)
From: Skip M. <sk...@po...> - 2013年05月31日 15:40:43
> Would you mind opening up an issue on github - this is definitely
> a bug (http://matplotlib.org/faq/troubleshooting_faq.html).
Done: https://github.com/matplotlib/matplotlib/issues/2104
Skip
From: Phil E. <pel...@gm...> - 2013年05月31日 15:33:56
Agreed. I've seen this a couple of times but never reproduced it so
elegantly. Would you mind opening up an issue on github - this is
definitely a bug (http://matplotlib.org/faq/troubleshooting_faq.html).
Thanks!
P.S. Welcome to the mailinglist :-)
On 31 May 2013 16:02, Skip Montanaro <sk...@po...> wrote:
> I'm not sure of the correct protocol (I just subscribed to report this
> problem), but the documentation said to report bugs here, and I saw no
> mention of this in Google searches of the list archives.
>
> The exception_to_str() function was changed between mpl 1.1 and 1.2.
> In my installation I show it going from this:
>
> def exception_to_str(s = None):
>
> sh = StringIO.StringIO()
> if s is not None: print >>sh, s
> traceback.print_exc(file=sh)
> return sh.getvalue()
>
> to this:
>
> def exception_to_str(s=None):
>
> sh = io.StringIO()
> if s is not None:
> print(s, file=sh)
> traceback.print_exc(file=sh)
> return sh.getvalue()
>
> At first glance, the change seems innocuous enough, but I think it
> introduced an error. (It appears that mpl 1.2 is supposed to work on
> Python 2.7 and 3.x.) From a thread I started on comp.lang.python
> (http://thread.gmane.org/gmane.comp.python.general/733938), it appears
> that io.StringIO instances only accept Unicode strings as input.
> Unless v 1.2 is only supposed to run on Python 3 (that doesn't seem to
> be the case), you need to do something to convert the traceback
> module's output to Unicode before feeding to the io.StringIO object.
>
> Here's a simple demonstration of the problem:
>
> % python2.7
> Python 2.7.5+ (2.7:93eb15779050, May 30 2013, 15:27:39)
> [GCC 4.4.6 [TWW]] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import traceback, StringIO, io
> >>> s1 = StringIO.StringIO()
> >>> traceback.print_stack(file=s1)
> >>> print repr(s1.getvalue())
> ' File "<stdin>", line 1, in <module>\n'
> >>>
> >>> s2 = io.StringIO()
> >>> traceback.print_stack(file=s2)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
> 269, in print_stack
> print_list(extract_stack(f, limit), file)
> File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
> 23, in print_list
> ' File "%s", line %d, in %s' % (filename,lineno,name))
> File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
> 13, in _print
> file.write(str+terminator)
> TypeError: unicode argument expected, got 'str'
>
> Skip Montanaro
> sk...@po...
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Skip M. <sk...@po...> - 2013年05月31日 15:02:54
I'm not sure of the correct protocol (I just subscribed to report this
problem), but the documentation said to report bugs here, and I saw no
mention of this in Google searches of the list archives.
The exception_to_str() function was changed between mpl 1.1 and 1.2.
In my installation I show it going from this:
def exception_to_str(s = None):
 sh = StringIO.StringIO()
 if s is not None: print >>sh, s
 traceback.print_exc(file=sh)
 return sh.getvalue()
to this:
def exception_to_str(s=None):
 sh = io.StringIO()
 if s is not None:
 print(s, file=sh)
 traceback.print_exc(file=sh)
 return sh.getvalue()
At first glance, the change seems innocuous enough, but I think it
introduced an error. (It appears that mpl 1.2 is supposed to work on
Python 2.7 and 3.x.) From a thread I started on comp.lang.python
(http://thread.gmane.org/gmane.comp.python.general/733938), it appears
that io.StringIO instances only accept Unicode strings as input.
Unless v 1.2 is only supposed to run on Python 3 (that doesn't seem to
be the case), you need to do something to convert the traceback
module's output to Unicode before feeding to the io.StringIO object.
Here's a simple demonstration of the problem:
% python2.7
Python 2.7.5+ (2.7:93eb15779050, May 30 2013, 15:27:39)
[GCC 4.4.6 [TWW]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import traceback, StringIO, io
>>> s1 = StringIO.StringIO()
>>> traceback.print_stack(file=s1)
>>> print repr(s1.getvalue())
' File "<stdin>", line 1, in <module>\n'
>>>
>>> s2 = io.StringIO()
>>> traceback.print_stack(file=s2)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
269, in print_stack
 print_list(extract_stack(f, limit), file)
 File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
23, in print_list
 ' File "%s", line %d, in %s' % (filename,lineno,name))
 File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
13, in _print
 file.write(str+terminator)
TypeError: unicode argument expected, got 'str'
Skip Montanaro
sk...@po...
From: Sudheer J. <sud...@ya...> - 2013年05月31日 13:50:24
Thank you both Paul and Eric the kind helping hands,
Sudheer
From: Pierre H. <pie...@cr...> - 2013年05月31日 11:15:18
Attachments: signature.asc
Hi,
A friend was just asking me about how to set grid style in matplotlibrc
to separate settings for minor and major grids.
As far as I understand, it's not possible because the rc file only
includes the following options :
grid.color, grid.linestyle and grid.linewidth
Would it make sense to add also grid.major.* and grid.minor.* (as it
already exists for xticks) ?
best,
Pierre
Sorry if this question was already discussed. I though it was, but a few
Google searches didn't point me to relevant content.
From: Eric F. <ef...@ha...> - 2013年05月31日 03:13:04
On 2013年05月30日 3:42 PM, Paul Hobson wrote:
>
>
>
> On Thu, May 30, 2013 at 6:28 PM, Sudheer Joseph
> <sud...@ya... <mailto:sud...@ya...>> wrote:
>
> Dear Users,
> Is there a way to set font size of error bar plot
> axis? I tried below one but get error that "'ErrorbarContainer'
> object has no attribute 'xaxis'"
> any help??
>
Paul is correct ("plt.tick_params(labelsize=14)"), but in addition, the 
error you are making is that errorbar does not return an Axes. To get a 
reference to the Axes you could follow the call to plt.errorbar() with 
"ax = plt.gca()".
> ax=plt.errorbar(y,x,err,label='STDV')
> plt.xlim(0,110)
> for tick in ax.xaxis.get_major_ticks():
> tick.label.set_fontsize(14)
>
>
> Use ax.tick_params
> (http://matplotlib.org/api/axes_api.html?highlight=tick_params#matplotlib.axes.Axes.tick_params).
>
> Hope that helps,
> -paul
>
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Paul H. <pmh...@gm...> - 2013年05月31日 01:43:04
On Thu, May 30, 2013 at 6:28 PM, Sudheer Joseph <sud...@ya...>wrote:
> Dear Users,
> Is there a way to set font size of error bar plot axis? I
> tried below one but get error that "'ErrorbarContainer' object has no
> attribute 'xaxis'"
> any help??
>
> ax=plt.errorbar(y,x,err,label='STDV')
> plt.xlim(0,110)
> for tick in ax.xaxis.get_major_ticks():
> tick.label.set_fontsize(14)
>
>
Use ax.tick_params (
http://matplotlib.org/api/axes_api.html?highlight=tick_params#matplotlib.axes.Axes.tick_params
).
Hope that helps,
-paul
From: Sudheer J. <sud...@ya...> - 2013年05月31日 01:28:10
Dear Users,
        Is there a way to set font size of error bar plot axis? I tried below one but get error that "'ErrorbarContainer' object has no attribute 'xaxis'"
any help??
ax=plt.errorbar(y,x,err,label='STDV')
plt.xlim(0,110)
for tick in ax.xaxis.get_major_ticks():
        tick.label.set_fontsize(14)
 
***************************************************************
Sudheer Joseph 
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo...@gm...;sud...@ya...
Web- http://oppamthadathil.tripod.com
***************************************************************
From: zetah <ot...@hu...> - 2013年05月30日 02:55:43
I got a revelation - as colorbar wasn't changing with animation iteration I put it in init() function and draw the first frame there.
Voila :) 
From: zetah <ot...@hu...> - 2013年05月30日 02:15:52
Hi, I'm stacked again, sorry, but I couldn't find any pointers with my google.
In my filled contour animation I thought to use colorbar instead complicating with contour labeling, which just makes animation too full. So after reading the docs, I used something like this simplified code:
==================================================
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
def init():
 return ax.cla(),
def animate(i):
 global t
 r = np.random.random(10)
 c = np.sin(2 * np.pi * r) * np.vstack(np.cos(2 * np.pi * r))
 ax.cla()
 cax = ax.contourf(c)
 cbar = fig.colorbar(cax, ticks=[0, .3, .6, 1])
 cbar.ax.set_yticklabels(['a', 'b', 'c', 'd'])
 return ax,
if __name__ == '__main__':
 fig = plt.figure()
 ax = fig.add_subplot(111)
 anim = animation.FuncAnimation(fig, animate, init_func=init,
 frames=100,
 interval=15,
 blit=True)
 anim.save('test.mp4', fps=15, extra_args=['-vcodec', 'libx264'])
==================================================
and noticed that colorbar object is not cleared from the scene, but it repeatedly fills the plot until there are only colorbars on it. Here is sample frame:
http://i.imgur.com/ydoUFrO.png
And I have no idea how to clean it. Can anyone tell me how to clean this colorbar while iterating animation?
Thanks
Hi all,
I just wanted to let you all know that Hans Petter Langtangen,
well-known author of books on scientific Python and long-time champion
of these tools at the University of Oslo for many years, has arranged
for a donation of 10,000ドル to support matplotlib's development.
Hans Petter is the Director of the Center for Biomedical Computing at
Simula (http://home.simula.no/~hpl), where a number of projects use
Python as key elements of their research, the Fenics platform being
among the most well-known (http://fenicsproject.org).
We have now confirmed that these funds have been transferred to the
NumFOCUS donations account, where Michael and the rest of the team can
make use of them.
I wanted to publicly thank Hans Petter and Simula Labs for
persistently jumping through the necessary hoops to make this
possible, and to Leah, Travis and Anthony at NumFOCUS for managing the
receiving side of things.
--
Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail
From: zetah <ot...@hu...> - 2013年05月29日 19:50:07
Benjamin Root wrote:
>The init() function only happens once. So, each call to 
>ax.contourf() just
>simply adds more contours on top of the previous (you just don't 
>see them
>because you don't have masked regions or transparency). I would 
>suggest
>doing an ax.cla() in the animate() function before doing 
>ax.contourf().
It's like you said.
Thanks for assistance :)
Cheers
From: Benjamin R. <ben...@ou...> - 2013年05月29日 19:31:59
On Wed, May 29, 2013 at 3:03 PM, zetah <ot...@hu...> wrote:
> Please consider this small script:
>
>
The init() function only happens once. So, each call to ax.contourf() just
simply adds more contours on top of the previous (you just don't see them
because you don't have masked regions or transparency). I would suggest
doing an ax.cla() in the animate() function before doing ax.contourf().
Cheers!
Ben Root
From: zetah <ot...@hu...> - 2013年05月29日 19:03:17
Please consider this small script:
============================================================
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from time import time
def init():
 return ax.cla()
def animate(i):
 global t
 r = np.random.random(10)
 c = np.sin(2 * np.pi * r) * np.vstack(np.cos(2 * np.pi * r))
 print(time() - t)
 t = time()
 return ax.contourf(c)
if __name__ == '__main__':
 t = time()
 fig = plt.figure()
 ax = fig.add_subplot(111)
 anim = animation.FuncAnimation(fig, animate, init_func=init,
 frames=100,
 interval=15,
 blit=True)
 anim.save('test.mp4', fps=15, extra_args=['-vcodec', 'libx264'])
============================================================
The output from this script is as follows:
============================================================
0.21799993515
0.375
0.28200006485
0.31200003624
0.26500010490
0.31299996376
0.35899996757
0.32800006866
0.34399986267
0.375
0.40600013732
0.39100003242
0.42200016975
0.46899986267
0.5
0.51600003242
0.5
0.54699993133
0.57800006866
0.57799983024
0.59400010108
0.60899996757
0.64100003242
0.65599989891
0.73399996757
0.71900010108
0.73399996757
0.76600003242
0.79699993133
0.81200003624
1.04699993134
0.86000013351
0.89100003242
0.90600013732
0.92199993133
0.92199993133
1.0
1.10899996758
1.01600003242
1.03099989891
1.06200003624
1.11000013351
1.45299983025
1.21900010109
1.34299993515
1.31299996376
1.35900020599
1.39099979401
1.3900001049
1.43799996376
1.42199993134
1.45300006866
1.48399996758
1.5
1.5
1.54700016975
1.54699993134
1.625
1.625
1.625
1.65700006485
1.68700003624
1.67199993134
1.75
1.73399996758
1.73399996758
1.78200006485
1.81200003624
1.82800006866
1.8599998951
1.84299993515
1.93700003624
1.93799996376
1.98399996758
1.96900010109
2.04699993134
2.03099989891
2.03100013733
2.06299996376
2.06200003624
2.10899996758
2.125
2.17199993134
2.14100003242
2.18700003624
2.21900010109
2.2349998951
2.2650001049
2.28100013733
2.28099989891
2.29600000381
2.32899999619
2.375
2.35899996758
2.42199993134
2.46900010109
2.46799993515
2.48500013351
2.5
2.51600003242
============================================================
So every loops is slower and slower. Now, my original script is more complicated, and when it reaches 100th frame the single loop takes half a minute to finish compared to half a second after the first loop. Can someone suggest what is wrong with the above code, and how to avoid this time aggregation on every loop?
Thanks
From: Albert K. <alb...@gm...> - 2013年05月28日 17:30:37
Correct.
On Tue, May 28, 2013 at 9:42 AM, zetah <ot...@hu...> wrote:
> Albert Kottke wrote:
> >
> >I had this problem as well. I think my solution was to tell the
> >garbage collector to collect.
> >
> >import gc
> >import numpy as np
> >import matplotlib.pyplot as plt
> >
> >def draw_fig(arr, fn):
> > fig = plt.figure()
> > ax = fig.add_subplot(111)
> > ax.contourf(arr)
> > plt.savefig(fn)
> > plt.close(fig)
> > gc.collect()
> >
> >I tried to test this with Python3.3, but didn't have any issues
> >with memory increasing when using 'plt.close'.
>
>
> Thanks Albert, that indeed does the trick :)
>
> If I understand your last sentence, you are saying garbage collector
> intervention isn't needed for Python 3.3.
>
>
> Cheers
>
>
From: zetah <ot...@hu...> - 2013年05月28日 16:42:53
Albert Kottke wrote:
>
>I had this problem as well. I think my solution was to tell the 
>garbage collector to collect.
>
>import gc
>import numpy as np
>import matplotlib.pyplot as plt
>
>def draw_fig(arr, fn):
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.contourf(arr)
> plt.savefig(fn)
> plt.close(fig)
> gc.collect()
>
>I tried to test this with Python3.3, but didn't have any issues 
>with memory increasing when using 'plt.close'.
Thanks Albert, that indeed does the trick :)
If I understand your last sentence, you are saying garbage collector intervention isn't needed for Python 3.3.
Cheers
From: Albert K. <alb...@gm...> - 2013年05月28日 16:25:52
I had this problem as well. I think my solution was to tell the garbage
collector to collect.
import gc
import numpy as np
import matplotlib.pyplot as plt
def draw_fig(arr, fn):
 fig = plt.figure()
 ax = fig.add_subplot(111)
 ax.contourf(arr)
 plt.savefig(fn)
 plt.close(fig)
 gc.collect()
I tried to test this with Python3.3, but didn't have any issues with memory
increasing when using 'plt.close'.
On Tue, May 28, 2013 at 8:04 AM, zetah <ot...@hu...> wrote:
> "zetah" wrote:
> >
> >Eric Firing wrote:
> >>
> >> plt.close(fig) # that should take care of it
> >
> >Thanks for your quick reply.
> >
> >I tried before posting `plt.close()` and it didn't work, but also
> >`plt.close(fig)` doesn't change memory pumping with every loop.
> >BTW, I'm on Windows with Matplotlib 1.2.1
>
> I solved the problem by using animation class. If was a bit tricky, as I
> had inner loops that also were producing plots for same sequence, and from
> what I understood about this class, iterator is "frames" argument in
> FuncAnimation() function, which also returns the frame, so you may imagine
> how I solved inner loops.
> I guess there is instrumentation for such case, but documentation about
> animation class is beyond my comprehension. Also couple of blogs explaining
> basics of FuncAnimation() function weren't very helpful to me. Maybe it's
> my limitation...
>
> Anyway, I'm still curious how to close figure from my initial message, so
> that memory won't leak. I welcome your replies
>
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: klo uo <kl...@gm...> - 2013年05月28日 15:19:31
On Tue, May 28, 2013 at 4:40 PM, Michael Droettboom wrote:
> Which version of Windows are you on? Apparently, the Segoe UI font is
> different on Windows 7 and 8 and I'd like to download and test with the
> correct one.
I'm on Windows XP, but problem was with the name of the font. This
font's name is "Segoe UI" and if I reference it in matplotlibrc as
"SegoeUI" (without space), then it works in all above vector formats.
"Segoe UI" works only in PDF.
From: Benjamin R. <ben...@ou...> - 2013年05月28日 15:19:18
On Tue, May 28, 2013 at 3:50 AM, Nils Wagner <ni...@go...> wrote:
> Hi all,
>
> I would like to add a legend to a 3D plot.
> However, the legend ist not visible in the example given below.
> Am I missing something ?
>
> Nils
>
> import numpy as np
> from mpl_toolkits.mplot3d import Axes3D
> import matplotlib.pyplot as plt
> import random
>
> def fun(x, y):
> return x**2 + y
> def fun1(x, y):
> return 10+x**2 + y
>
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> x = y = np.arange(-3.0, 3.0, 0.05)
> X, Y = np.meshgrid(x, y)
> zs = np.array([fun(x,y) for x,y in zip(np.ravel(X), np.ravel(Y))])
> Z = zs.reshape(X.shape)
> zs = np.array([fun1(x,y) for x,y in zip(np.ravel(X), np.ravel(Y))])
> Z1 = zs.reshape(X.shape)
>
> ax.plot_surface(X, Y, Z, label=r'$f$')
> ax.plot_surface(X, Y, Z1,label=r'$f_1$')
>
> ax.set_xlabel('X Label')
> ax.set_ylabel('Y Label')
> ax.set_zlabel('Z Label')
> ax.legend()
> plt.show()
>
>
plot_surface() does not have any default representation in a legend. I
have never thought about it before, but what would one want to display for
it? It is kind of like wanting a legend entry for an imshow() or pcolor()
display. If you have something in mind to display, I would suggest using
proxy artists.
Cheers!
Ben Root
From: zetah <ot...@hu...> - 2013年05月28日 15:04:39
"zetah" wrote:
>
>Eric Firing wrote:
>>
>> plt.close(fig) # that should take care of it
>
>Thanks for your quick reply.
>
>I tried before posting `plt.close()` and it didn't work, but also 
>`plt.close(fig)` doesn't change memory pumping with every loop.
>BTW, I'm on Windows with Matplotlib 1.2.1
I solved the problem by using animation class. If was a bit tricky, as I had inner loops that also were producing plots for same sequence, and from what I understood about this class, iterator is "frames" argument in FuncAnimation() function, which also returns the frame, so you may imagine how I solved inner loops.
I guess there is instrumentation for such case, but documentation about animation class is beyond my comprehension. Also couple of blogs explaining basics of FuncAnimation() function weren't very helpful to me. Maybe it's my limitation...
Anyway, I'm still curious how to close figure from my initial message, so that memory won't leak. I welcome your replies
From: Michael D. <md...@st...> - 2013年05月28日 14:42:59
Which version of Windows are you on? Apparently, the Segoe UI font is 
different on Windows 7 and 8 and I'd like to download and test with the 
correct one.
Mike
On 05/28/2013 06:12 AM, klo uo wrote:
> As suggested by Phil, I'm reposting github issue #2067 on this list.
>
> I use MPL 1.2.1 on Windows with Python 2.7.5. In my matplotlibrc I've
> set sans-serif font to "Segoe UI".
>
> Now, if I try to save a plot to PDF, MPL saves it fine, but if I try
> PS or EPS or SVG it fails, because of the font set. (If I don't change
> the font everything is fine)
>
> Here is PDF info from mutool:
> ============================================================
> PDF-1.4
> Info object (27 0 R):
> <<
> /CreationDate (D:20130528120149+02'00')
> /Producer (matplotlib pdf backend)
> /Creator (matplotlib 1.2.1, http://matplotlib.sf.net)
> Pages: 1
>
> Retrieving info from pages 1-1...
> Mediaboxes (1):
> 1 ( 10 0 R): [ 0 0 576 432 ]
>
> Fonts (1):
> 1 ( 10 0 R): Type3 'SegoeUI' (14 0 R)
> ============================================================
>
>
> So I wonder how can MPL output PDF, but can't output PS/EPS, let aside SVG?
>
>
> And here is full trace from IPython:
> ================================================================================
> KeyError Traceback (most recent call last)
> <ipython-input-63-6bec7f50eb05> in <module>()
> ----> 1 savefig('test.eps')
>
> C:\Python27\lib\site-packages\matplotlib\pyplot.pyc in savefig(*args, **kwargs)
> 470 def savefig(*args, **kwargs):
> 471 fig = gcf()
> --> 472 return fig.savefig(*args, **kwargs)
> 473
> 474 @docstring.copy_dedent(Figure.ginput)
>
> C:\Python27\lib\site-packages\matplotlib\figure.pyc in savefig(self,
> *args, **kwargs)
> 1368 kwargs.setdefault('edgecolor',
> rcParams['savefig.edgecolor'])
> 1369
> -> 1370 self.canvas.print_figure(*args, **kwargs)
> 1371
> 1372 if transparent:
>
> C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc in
> print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
> format, **kwargs)
> 2094 orientation=orientation,
> 2095 bbox_inches_restore=_bbox_inches_restore,
> -> 2096 **kwargs)
> 2097 finally:
> 2098 if bbox_inches and restore_bbox:
>
> C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc in
> print_eps(self, *args, **kwargs)
> 1841 from backends.backend_ps import FigureCanvasPS # lazy import
> 1842 ps = self.switch_backends(FigureCanvasPS)
> -> 1843 return ps.print_eps(*args, **kwargs)
> 1844
> 1845 def print_pdf(self, *args, **kwargs):
>
> C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
> print_eps(self, outfile, *args, **kwargs)
> 972
> 973 def print_eps(self, outfile, *args, **kwargs):
> --> 974 return self._print_ps(outfile, 'eps', *args, **kwargs)
> 975
> 976
>
> C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
> _print_ps(self, outfile, format, *args, **kwargs)
> 1005 self._print_figure(outfile, format, imagedpi,
> facecolor, edgecolor,
> 1006 orientation, isLandscape, papertype,
> -> 1007 **kwargs)
> 1008
> 1009 def _print_figure(self, outfile, format, dpi=72,
> facecolor='w', edgecolor='w',
>
> C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
> _print_figure(self, outfile, format, dpi, facecolor, edgecolor,
> orientation, isLandscape, papertype, **kwargs)
> 1098 bbox_inches_restore=_bbox_inches_restore)
> 1099
> -> 1100 self.figure.draw(renderer)
> 1101
> 1102 if dryrun: # return immediately if dryrun (tightbbox=True)
>
> C:\Python27\lib\site-packages\matplotlib\artist.pyc in
> draw_wrapper(artist, renderer, *args, **kwargs)
> 52 def draw_wrapper(artist, renderer, *args, **kwargs):
> 53 before(artist, renderer)
> ---> 54 draw(artist, renderer, *args, **kwargs)
> 55 after(artist, renderer)
> 56
>
> C:\Python27\lib\site-packages\matplotlib\figure.pyc in draw(self, renderer)
> 1004 dsu.sort(key=itemgetter(0))
> 1005 for zorder, a, func, args in dsu:
> -> 1006 func(*args)
> 1007
> 1008 renderer.close_group('figure')
>
> C:\Python27\lib\site-packages\matplotlib\artist.pyc in
> draw_wrapper(artist, renderer, *args, **kwargs)
> 52 def draw_wrapper(artist, renderer, *args, **kwargs):
> 53 before(artist, renderer)
> ---> 54 draw(artist, renderer, *args, **kwargs)
> 55 after(artist, renderer)
> 56
>
> C:\Python27\lib\site-packages\matplotlib\axes.pyc in draw(self,
> renderer, inframe)
> 2084
> 2085 for zorder, a in dsu:
> -> 2086 a.draw(renderer)
> 2087
> 2088 renderer.close_group('axes')
>
> C:\Python27\lib\site-packages\matplotlib\artist.pyc in
> draw_wrapper(artist, renderer, *args, **kwargs)
> 52 def draw_wrapper(artist, renderer, *args, **kwargs):
> 53 before(artist, renderer)
> ---> 54 draw(artist, renderer, *args, **kwargs)
> 55 after(artist, renderer)
> 56
>
> C:\Python27\lib\site-packages\matplotlib\axis.pyc in draw(self,
> renderer, *args, **kwargs)
> 1053
> 1054 for tick in ticks_to_draw:
> -> 1055 tick.draw(renderer)
> 1056
> 1057 # scale up the axis label box to also find the neighbors, not
>
> C:\Python27\lib\site-packages\matplotlib\artist.pyc in
> draw_wrapper(artist, renderer, *args, **kwargs)
> 52 def draw_wrapper(artist, renderer, *args, **kwargs):
> 53 before(artist, renderer)
> ---> 54 draw(artist, renderer, *args, **kwargs)
> 55 after(artist, renderer)
> 56
>
> C:\Python27\lib\site-packages\matplotlib\axis.pyc in draw(self, renderer)
> 238
> 239 if self.label1On:
> --> 240 self.label1.draw(renderer)
> 241 if self.label2On:
> 242 self.label2.draw(renderer)
>
> C:\Python27\lib\site-packages\matplotlib\artist.pyc in
> draw_wrapper(artist, renderer, *args, **kwargs)
> 52 def draw_wrapper(artist, renderer, *args, **kwargs):
> 53 before(artist, renderer)
> ---> 54 draw(artist, renderer, *args, **kwargs)
> 55 after(artist, renderer)
> 56
>
> C:\Python27\lib\site-packages\matplotlib\text.pyc in draw(self, renderer)
> 594 renderer.draw_text(gc, x, y, clean_line,
> 595 self._fontproperties, angle,
> --> 596 ismath=ismath)
> 597
> 598 gc.restore()
>
> C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
> draw_text(self, gc, x, y, s, prop, angle, ismath)
> 749
> 750 self.set_color(*gc.get_rgb())
> --> 751 self.set_font(font.get_sfnt()[(1,0,0,6)],
> prop.get_size_in_points())
> 752
> 753 cmap = font.get_charmap()
>
> KeyError: (1, 0, 0, 6)
> ================================================================================
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: ratomatrix <rat...@gm...> - 2013年05月28日 11:32:25
Hi, 
Gregorio Bastardo wrote
> When I use the "Zoom-to-rectangle" button of
> the navigation toolbar while holding the x or y key, sometimes nothing
> happens when the mouse is released.
I have also experienced the same behavior, and I still don't know what it
exactly depends on. It works most of the time, but sometimes it is almost
impossible to zoom to the desired area.
Gregorio Bastardo wrote
> python 2.7.4 win32
> matplotlib 1.1.1 and 1.2.1
> PyQt4 QtCore 4.8.3
> PySide QtCore 4.8.3
> PySide 1.1.2
I have python 2.7.3 win32 with matplotlib 1.1.1 and PySide 1.1.2, but it is
the same with the default Tk backend as well.
Any help would be appreciated.
Thanks,
Tom
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/constrained-rectangular-zoom-does-not-always-work-with-Qt4-backend-tp41108p41142.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: klo uo <kl...@gm...> - 2013年05月28日 10:13:06
As suggested by Phil, I'm reposting github issue #2067 on this list.
I use MPL 1.2.1 on Windows with Python 2.7.5. In my matplotlibrc I've
set sans-serif font to "Segoe UI".
Now, if I try to save a plot to PDF, MPL saves it fine, but if I try
PS or EPS or SVG it fails, because of the font set. (If I don't change
the font everything is fine)
Here is PDF info from mutool:
============================================================
PDF-1.4
Info object (27 0 R):
<<
 /CreationDate (D:20130528120149+02'00')
 /Producer (matplotlib pdf backend)
 /Creator (matplotlib 1.2.1, http://matplotlib.sf.net)
>>
Pages: 1
Retrieving info from pages 1-1...
Mediaboxes (1):
 1 ( 10 0 R): [ 0 0 576 432 ]
Fonts (1):
 1 ( 10 0 R): Type3 'SegoeUI' (14 0 R)
============================================================
So I wonder how can MPL output PDF, but can't output PS/EPS, let aside SVG?
And here is full trace from IPython:
================================================================================
KeyError Traceback (most recent call last)
<ipython-input-63-6bec7f50eb05> in <module>()
----> 1 savefig('test.eps')
C:\Python27\lib\site-packages\matplotlib\pyplot.pyc in savefig(*args, **kwargs)
 470 def savefig(*args, **kwargs):
 471 fig = gcf()
--> 472 return fig.savefig(*args, **kwargs)
 473
 474 @docstring.copy_dedent(Figure.ginput)
C:\Python27\lib\site-packages\matplotlib\figure.pyc in savefig(self,
*args, **kwargs)
 1368 kwargs.setdefault('edgecolor',
rcParams['savefig.edgecolor'])
 1369
-> 1370 self.canvas.print_figure(*args, **kwargs)
 1371
 1372 if transparent:
C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
format, **kwargs)
 2094 orientation=orientation,
 2095 bbox_inches_restore=_bbox_inches_restore,
-> 2096 **kwargs)
 2097 finally:
 2098 if bbox_inches and restore_bbox:
C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc in
print_eps(self, *args, **kwargs)
 1841 from backends.backend_ps import FigureCanvasPS # lazy import
 1842 ps = self.switch_backends(FigureCanvasPS)
-> 1843 return ps.print_eps(*args, **kwargs)
 1844
 1845 def print_pdf(self, *args, **kwargs):
C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
print_eps(self, outfile, *args, **kwargs)
 972
 973 def print_eps(self, outfile, *args, **kwargs):
--> 974 return self._print_ps(outfile, 'eps', *args, **kwargs)
 975
 976
C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
_print_ps(self, outfile, format, *args, **kwargs)
 1005 self._print_figure(outfile, format, imagedpi,
facecolor, edgecolor,
 1006 orientation, isLandscape, papertype,
-> 1007 **kwargs)
 1008
 1009 def _print_figure(self, outfile, format, dpi=72,
facecolor='w', edgecolor='w',
C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
_print_figure(self, outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype, **kwargs)
 1098 bbox_inches_restore=_bbox_inches_restore)
 1099
-> 1100 self.figure.draw(renderer)
 1101
 1102 if dryrun: # return immediately if dryrun (tightbbox=True)
C:\Python27\lib\site-packages\matplotlib\artist.pyc in
draw_wrapper(artist, renderer, *args, **kwargs)
 52 def draw_wrapper(artist, renderer, *args, **kwargs):
 53 before(artist, renderer)
---> 54 draw(artist, renderer, *args, **kwargs)
 55 after(artist, renderer)
 56
C:\Python27\lib\site-packages\matplotlib\figure.pyc in draw(self, renderer)
 1004 dsu.sort(key=itemgetter(0))
 1005 for zorder, a, func, args in dsu:
-> 1006 func(*args)
 1007
 1008 renderer.close_group('figure')
C:\Python27\lib\site-packages\matplotlib\artist.pyc in
draw_wrapper(artist, renderer, *args, **kwargs)
 52 def draw_wrapper(artist, renderer, *args, **kwargs):
 53 before(artist, renderer)
---> 54 draw(artist, renderer, *args, **kwargs)
 55 after(artist, renderer)
 56
C:\Python27\lib\site-packages\matplotlib\axes.pyc in draw(self,
renderer, inframe)
 2084
 2085 for zorder, a in dsu:
-> 2086 a.draw(renderer)
 2087
 2088 renderer.close_group('axes')
C:\Python27\lib\site-packages\matplotlib\artist.pyc in
draw_wrapper(artist, renderer, *args, **kwargs)
 52 def draw_wrapper(artist, renderer, *args, **kwargs):
 53 before(artist, renderer)
---> 54 draw(artist, renderer, *args, **kwargs)
 55 after(artist, renderer)
 56
C:\Python27\lib\site-packages\matplotlib\axis.pyc in draw(self,
renderer, *args, **kwargs)
 1053
 1054 for tick in ticks_to_draw:
-> 1055 tick.draw(renderer)
 1056
 1057 # scale up the axis label box to also find the neighbors, not
C:\Python27\lib\site-packages\matplotlib\artist.pyc in
draw_wrapper(artist, renderer, *args, **kwargs)
 52 def draw_wrapper(artist, renderer, *args, **kwargs):
 53 before(artist, renderer)
---> 54 draw(artist, renderer, *args, **kwargs)
 55 after(artist, renderer)
 56
C:\Python27\lib\site-packages\matplotlib\axis.pyc in draw(self, renderer)
 238
 239 if self.label1On:
--> 240 self.label1.draw(renderer)
 241 if self.label2On:
 242 self.label2.draw(renderer)
C:\Python27\lib\site-packages\matplotlib\artist.pyc in
draw_wrapper(artist, renderer, *args, **kwargs)
 52 def draw_wrapper(artist, renderer, *args, **kwargs):
 53 before(artist, renderer)
---> 54 draw(artist, renderer, *args, **kwargs)
 55 after(artist, renderer)
 56
C:\Python27\lib\site-packages\matplotlib\text.pyc in draw(self, renderer)
 594 renderer.draw_text(gc, x, y, clean_line,
 595 self._fontproperties, angle,
--> 596 ismath=ismath)
 597
 598 gc.restore()
C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in
draw_text(self, gc, x, y, s, prop, angle, ismath)
 749
 750 self.set_color(*gc.get_rgb())
--> 751 self.set_font(font.get_sfnt()[(1,0,0,6)],
prop.get_size_in_points())
 752
 753 cmap = font.get_charmap()
KeyError: (1, 0, 0, 6)
================================================================================
From: zetah <ot...@hu...> - 2013年05月28日 08:15:57
Eric Firing wrote:
>
> plt.close(fig) # that should take care of it
Thanks for your quick reply.
I tried before posting `plt.close()` and it didn't work, but also `plt.close(fig)` doesn't change memory pumping with every loop.
BTW, I'm on Windows with Matplotlib 1.2.1
From: Eric F. <ef...@ha...> - 2013年05月28日 08:04:17
On 2013年05月27日 9:51 PM, zetah wrote:
> Hi,
>
> if I use something like this:
>
> ==================================================
> import numpy as np
> import matplotlib.pyplot as plt
>
> def draw_fig(arr, fn):
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.contourf(arr)
> plt.savefig(fn)
 plt.close(fig) # that should take care of it
>
> if __name__ == '__main__':
> 	for i in range(10):
> 		draw_fig(np.random.random((10, 10)), 'fig_%02d.png' % i)
> ==================================================
>
> memory usage grows with every loop, so I can't plot this way many sequences.
>
> I know there is animation class in Matplotlib, but this way is easier to me, and I think I miss something fundamental because this is happening. How can I avoid memory leak using this approach?
>
> Thanks
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
1 message has been excluded from this view by a project administrator.

Showing results of 141

1 2 3 .. 6 > >> (Page 1 of 6)
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 によって変換されたページ (->オリジナル) /