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





Showing 20 results of 20

From: Rich F. <wha...@fs...> - 2008年03月17日 22:22:28
Eric Firing wrote:
>
> The transforms can be modified at drawing time, so you need to get the 
> pixel locations after the plot has been drawn. Are you doing this?
Eric,
Thank you! I put the transforms after savefig() and it works like a 
champ now.
Rich
From: Eric F. <ef...@ha...> - 2008年03月17日 21:22:33
It sounds like what you want it the pyplot figlegend command:
def figlegend(handles, labels, loc, **kwargs):
 """
 Place a legend in the figure. Labels are a sequence of
 strings, handles is a sequence of line or patch instances, and
 loc can be a string r an integer specifying the legend
 location
 USAGE:
 legend( (line1, line2, line3),
 ('label1', 'label2', 'label3'),
 'upper right')
 See help(legend) for information about the location codes
 A matplotlib.legend.Legend instance is returned
 """
or you could directly use the Figure.legend method. The relevant part 
of the docstring regarding placement in the figure is here:
 The LOC location codes are
 'best' : 0, (currently not supported for figure legends)
 'upper right' : 1,
 'upper left' : 2,
 'lower left' : 3,
 'lower right' : 4,
 'right' : 5,
 'center left' : 6,
 'center right' : 7,
 'lower center' : 8,
 'upper center' : 9,
 'center' : 10,
 loc can also be an (x,y) tuple in figure coords, which
 specifies the lower left of the legend box. figure coords are
 (0,0) is the left, bottom of the figure and 1,1 is the right,
 top.
Eric
Chris Withers wrote:
> Matthias Michler wrote:
>> sorry I don't understand what you are exactly looking for. Maybe you could 
>> explain it once more. 
> 
> Well, what you provided was pretty close, it's just that the legend was 
> partly placed outside the figure...
> 
>> In general I think all one can do is to play around with the parameters 
>> in 'subplots_adjust' and the location in 'legend' to get the best result. 
>> I'm not an expert but I think there's no default behaviour covering all needs 
>> (outside the axes and best located), because for example the legend width is 
>> influenced by the length of the labels.
> 
> Right, this is the problem. The location your example provided is 
> perfect, except that I may have no control over the length of the legend 
> text, and so need to find a way to make sure the figure size is such 
> that the legend doesn't end up being half off the figure...
> 
> Anyone know how to do that?
> 
> (and thanks to Matthias for all his help! :-) )
> 
> cheers,
> 
> Chris
> 
From: Eric F. <ef...@ha...> - 2008年03月17日 21:17:53
Rich,
The transforms can be modified at drawing time, so you need to get the 
pixel locations after the plot has been drawn. Are you doing this?
Eric
Rich Fought wrote:
> Rich Fought wrote:
>> I'm plotting some grid data using pcolor, and trying to get canvas pixel 
>> locations of data points using the
>>
>> ax.transData.xy_tup()
>>
>> method. I am saving these figures to PNG files using the default Agg 
>> backend. When I open these images up in Gimp and check the pixel 
>> locations, the X pixel locations are accurate, but the Y pixel locations 
>> I am getting from matplotlib seem to be exaggerated the further away 
>> from Y=0 I go. Am I using this method incorrectly? Could this be an 
>> artifact of the rendering to PNG?
>> 
> 
> I determined what is causing the exaggerated y-pixel values. I was using
> 
> axes().set_aspect('equal')
> 
> on the figure and this apparently does not get taken into account when using
> 
> ax.transData.xy_tup()
> 
> I tried setting the aspect in the original fig.add_subplot, but got the 
> same incorrect results.
> 
> ax = fig.add_subplot(111, aspect='equal')
> 
> Leaving the aspect alone gives correct pixel results.
> 
> Is this a bug, or expected behavior?
> 
> Rich
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Michael R. <mic...@ya...> - 2008年03月17日 19:21:08
Attachments: finance.py.patch
Hi all,
I apologize in advance if these issues have already been addressed. I did a
search of the mailing lists and did not find them discussed but I may have
missed them.
I had some trouble getting the historical quotes data from yahoo to work,
apparently because yahoo changed the format of the dates in their output files
- once I changed the date format string in finance.py it worked fine.
Also the color of the candlestick shadow line that shows the day's range was
hard-coded to be black. Because it didn't show up on my charts with black
backgrounds, I changed the code to make the shadow match the color of the
candle's real body.
I am attaching a diff of my finance.py, which on my Debian Etch system came in
a package that says its version is 0.87.7-0.3.
Please keep in mind that I do not intend the code I am attaching to be a
comprehensive fix, just a simple kludge. I am totally new both to matplotlib
and to python and I have only done as much kludge-ing as was necessary to get
the code to do what I needed it to do right now. I will leave doing things the
right way, to people already more familiar with the language and the code.
Peace,
Michael
 ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
From: Eric F. <ef...@ha...> - 2008年03月17日 18:29:29
Chris Withers wrote:
> Hi All,
> 
> How do I go about showing minor ticks as lines across the whole plot, as 
> opposed to just little ticks at the side?
> 
> I can get the major ticks to show by doing grid(True), but how do I get 
> the same effect for minor ticks?
Try
grid(True, which='minor')
Eric
> 
> cheers,
> 
> Chris
> 
From: Eric F. <ef...@ha...> - 2008年03月17日 18:14:18
Chris Withers wrote:
> Eric Firing wrote:
>> Chris,
>>
>> Use masked arrays. See masked_demo.py in the mpl examples subdirectory.
> 
> Hi Eric,
> 
> I took a look at that, but it uses:
> 
> import matplotlib.numerix.npyma as ma
> 
> ...and matplotlib.numerix isn't listed in the API reference. Where are 
> the docs for this?
numerix is obsolete, and numerix.npyma was a temporary method to provide 
access to either of two masked array implementations. It is probably 
time for me to remove it from the examples. Substitute
import numpy.ma as ma
The ma module is documented as part of numpy.
> 
> Specifically, what I have is an array like so:
> 
> ['','','',1.1,2.2]
Try something like this:
import numpy.ma as ma
from pylab import *
aa = [3.4, 2.5, '','','',1.1,2.2]
def to_num(arg):
 if arg == '':
 return 9999.0
 return arg
aanum = array([to_num(arg) for arg in aa])
aamasked = ma.masked_where(aanum==9999.0, aanum)
plot(aamasked)
show()
Eric
> 
> I want to mask the strings out so I don't get ValueErrors raised when I 
> call plot functions with that array.
> 
> How should I do that?
> 
> cheers,
> 
> Chris
> 
From: Chris W. <ch...@si...> - 2008年03月17日 17:23:49
Matthias Michler wrote:
> sorry I don't understand what you are exactly looking for. Maybe you could 
> explain it once more. 
Well, what you provided was pretty close, it's just that the legend was 
partly placed outside the figure...
> In general I think all one can do is to play around with the parameters 
> in 'subplots_adjust' and the location in 'legend' to get the best result. 
> I'm not an expert but I think there's no default behaviour covering all needs 
> (outside the axes and best located), because for example the legend width is 
> influenced by the length of the labels.
Right, this is the problem. The location your example provided is 
perfect, except that I may have no control over the length of the legend 
text, and so need to find a way to make sure the figure size is such 
that the legend doesn't end up being half off the figure...
Anyone know how to do that?
(and thanks to Matthias for all his help! :-) )
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Chris W. <ch...@si...> - 2008年03月17日 17:20:17
Hi All,
How do I go about showing minor ticks as lines across the whole plot, as 
opposed to just little ticks at the side?
I can get the major ticks to show by doing grid(True), but how do I get 
the same effect for minor ticks?
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Chris W. <ch...@si...> - 2008年03月17日 17:18:52
Matthias Michler wrote:
> you can try xlabel of an empty string:
> 
> xlabel(' ')
Thanks, and yes, a truly empty string xlabel(''), works :-)
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Mark B. <ma...@gm...> - 2008年03月17日 16:50:54
Hello Bernhard and others -
I tried all the options, but nothing works.
Whenever I type a greek symbol in mathtext and save the figure as eps, the
greek symbols don't show up. Confirmed on several windows machines. Python
2.4. mpl 0.91.2. (but it worked fine under 0.90.1). Does anybody else have
this problem?
It is starting to look like a bug. Thanks, Mark
On Fri, Mar 14, 2008 at 5:06 PM, Bernhard Voigt <Ber...@de...>
wrote:
> what are the values of pdf and ps fonttype in your rc file?
>
> try using this:
> ps.fonttype : 3 # Output Type 3 (Type3) or Type 42
> (TrueType)
> pdf.fonttype : 3 # Output Type 3 (Type3) or Type 42
> (TrueType)
>
> this includes the missing symbols into the ps/pdf file, if you choose type
> 42 the complete font will be inserted in the resulting file.
>
> in addition check the mathtext.fontset setting, try using stix or cm:
> mathtext.fontset: cm
>
> best wishes, bernhard
>
>
>
> On Fri, Mar 14, 2008 at 2:15 PM, Mark Bakker <ma...@gm...> wrote:
>
> > Hello -
> >
> > I am trying this again. I recently upgraded to 0.91.2, and export of
> > mathtext to eps files seems broken (at least with the default matplotlibrc
> > file).
> >
> > Figure looks great on the screen (interactive mode). Exporting to png
> > still works fine.
> >
> > But writing to eps file, the greek symbols (I tried \theta and
> > \lambda) don't show up at all, while the latin symbols (a,b,c,etc) look very
> > ugly (different font than used to). Any suggestions? Anybody seenig the same
> > behavior?
> >
> > Thanks, Mark
> >
> >
> >
> >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
From: Matthias M. <Mat...@gm...> - 2008年03月17日 16:47:17
Hi Chris,
sorry I don't understand what you are exactly looking for. Maybe you could 
explain it once more. 
In general I think all one can do is to play around with the parameters 
in 'subplots_adjust' and the location in 'legend' to get the best result. 
I'm not an expert but I think there's no default behaviour covering all needs 
(outside the axes and best located), because for example the legend width is 
influenced by the length of the labels.
much effort and best regards
Matthias 
On Monday 17 March 2008 17:13, Chris Withers wrote:
> Hi Matthias,
>
> Matthias Michler wrote:
> > I'm not sure if there was an example in matplotlib, but the following
> > works for me:
> > ---------------------------------------------------------------------
> > from pylab import *
> > figure()
> > subplot(111)
> > subplots_adjust(right=0.7)
> > plot(arange(10), label='linear')
> > plot(arange(10)**2, label='quadratic')
> > legend(loc=(1.1,0.5))
> > show()
> > ------------------------------------------------------------------------
>
> Thanks for this. This is exactly what I was after except that the legend
> now appears about 25% off the right hand of the screen or whatever I
> save the figure to.
>
> How can I have the legend as placed above but with the whole of it showing?
>
> cheers,
>
> Chris
From: Matthias M. <Mat...@gm...> - 2008年03月17日 16:39:21
Hello Chris,
you can try xlabel of an empty string:
 
xlabel(' ')
regards
Matthias
On Monday 17 March 2008 17:11, Chris Withers wrote:
> Hi All,
>
> I'm using plot_date to plot some dates, but this sets an xlabel, and I
> don't want the plot to have an xlabel.
>
> How do I remove it?
>
> I tried:
>
> xlabel(None)
>
> ...but that just set the xlabel to 'None'...
>
> cheers,
>
> Chris
From: Chris W. <ch...@si...> - 2008年03月17日 16:13:21
Hi Matthias,
Matthias Michler wrote:
> I'm not sure if there was an example in matplotlib, but the following works 
> for me:
> ---------------------------------------------------------------------
> from pylab import *
> figure()
> subplot(111)
> subplots_adjust(right=0.7)
> plot(arange(10), label='linear')
> plot(arange(10)**2, label='quadratic')
> legend(loc=(1.1,0.5))
> show()
> ------------------------------------------------------------------------
Thanks for this. This is exactly what I was after except that the legend 
 now appears about 25% off the right hand of the screen or whatever I 
save the figure to.
How can I have the legend as placed above but with the whole of it showing?
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Chris W. <ch...@si...> - 2008年03月17日 16:11:17
Hi All,
I'm using plot_date to plot some dates, but this sets an xlabel, and I 
don't want the plot to have an xlabel.
How do I remove it?
I tried:
xlabel(None)
...but that just set the xlabel to 'None'...
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Rich F. <wha...@fs...> - 2008年03月17日 14:12:30
Rich Fought wrote:
> I'm plotting some grid data using pcolor, and trying to get canvas pixel 
> locations of data points using the
>
> ax.transData.xy_tup()
>
> method. I am saving these figures to PNG files using the default Agg 
> backend. When I open these images up in Gimp and check the pixel 
> locations, the X pixel locations are accurate, but the Y pixel locations 
> I am getting from matplotlib seem to be exaggerated the further away 
> from Y=0 I go. Am I using this method incorrectly? Could this be an 
> artifact of the rendering to PNG?
> 
I determined what is causing the exaggerated y-pixel values. I was using
axes().set_aspect('equal')
on the figure and this apparently does not get taken into account when using
ax.transData.xy_tup()
I tried setting the aspect in the original fig.add_subplot, but got the 
same incorrect results.
ax = fig.add_subplot(111, aspect='equal')
Leaving the aspect alone gives correct pixel results.
Is this a bug, or expected behavior?
Rich
From: Einar M. E. <ein...@gm...> - 2008年03月17日 12:08:03
Hi all,
I'm trying to find ways to make the file-size of my PNG images smaller.
When I generate my 660*440px image I get a big 168kb file.
(8bit RGB color model, has an alpha channel (need that) but no
interlacing scheme)
Here it is:
http://metphys.org/eme/T05.png
I'm using the savefig method of-course.
To see how much I could compress it I used pngcrush (the best tool
according to the interwebs) and got it down to 128kb.
But thats still way to large for my intended use. (plotting results
from an operational weather model, see. www.belgingur.is
We are currently using IDL.)
 From what I've read about PNG files, which is supposed to be rather
compact image format, it seems to me that the most effective way is
to have an indexed color table.
So to cut it short:
Is there any way to save a PNG file with an indexed color table?
Or do you see any other way to shrink the files?
Best regards.
Einar M. Einarsson
www.belgingur.is
From: Matthias M. <Mat...@gm...> - 2008年03月17日 12:00:23
Hello Chris,
I'm not sure if there was an example in matplotlib, but the following works 
for me:
---------------------------------------------------------------------
from pylab import *
figure()
subplot(111)
subplots_adjust(right=0.7)
plot(arange(10), label='linear')
plot(arange(10)**2, label='quadratic')
legend(loc=(1.1,0.5))
show()
------------------------------------------------------------------------
I hope this is useful to you.
best regards
Matthias
On Monday 17 March 2008 12:42, Chris Withers wrote:
> Hi All,
>
> How would I go about placing the legend outside the plot area?
>
> All the parameters to legend seem to place the legend somewhere within
> the plot and I'd like to place it outside the plot, either above, below
> or, most commonly, to the right, in the same way as the Excel legend
> positions allow.
>
> cheers,
>
> Chris
From: Chris W. <ch...@si...> - 2008年03月17日 11:43:48
Hi All,
I'm wondering what work people have done with matplotlib in 
multi-threaded environments such as your average python web framework.
Is matplotlib threadsafe?
How have people gone about safely using it in a multi-threaded environment?
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Chris W. <ch...@si...> - 2008年03月17日 11:42:38
Hi All,
How would I go about placing the legend outside the plot area?
All the parameters to legend seem to place the legend somewhere within 
the plot and I'd like to place it outside the plot, either above, below 
or, most commonly, to the right, in the same way as the Excel legend 
positions allow.
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Chris W. <ch...@si...> - 2008年03月17日 10:36:37
Eric Firing wrote:
> Chris,
> 
> Use masked arrays. See masked_demo.py in the mpl examples subdirectory.
Hi Eric,
I took a look at that, but it uses:
import matplotlib.numerix.npyma as ma
...and matplotlib.numerix isn't listed in the API reference. Where are 
the docs for this?
Specifically, what I have is an array like so:
['','','',1.1,2.2]
I want to mask the strings out so I don't get ValueErrors raised when I 
call plot functions with that array.
How should I do that?
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk

Showing 20 results of 20

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