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






Showing results of 28

1 2 > >> (Page 1 of 2)
> There's no way around the ``Decimal``? Otherwise I cannot confirm the
> inelegancyness except this construct ;-)
the moneyfmt routine I downloaded requires the Decimal package (i.e decimal.Decimal). I didn't have time to try writing my own version. It has a bug that if you specify number of decimal places = 0 it shows the trailing decimal point.
- dharhas
> Just got Goekhan's message, try a combination of both, might be worth.
a little inelegant but I got it working by combining both ideas:
def thousands(x, pos):
 'The two args are the value and tick position'
 xnew = moneyfmt(Decimal(x.__str__()))
 return xnew
where moneyfmt is the function defined in Gokhan's link.
and then:
formatter = FuncFormatter(thousands)
...
ax1.yaxis.set_major_formatter(formatter)
thanks
- d
From: Jonathan S. <js...@cf...> - 2010年10月19日 19:59:05
Friedrich,
Our e-mails crossed. I don't think the numbers need to have the same
exponent. I would go with (d) as my example does. The more difficult
part to my mind is the number of significant digits to use. The current
code that determines whether to use an offset or not must look at the
number of significant digits needed to represent the ticklabels. To me
what would be optimal is to, by default, use scientific notation (when
the ticklabel numbers are larger or smaller than some range, say 10^3
and 10^-3) except when an offset is called for, say more than 3
significant digits are needed to represent the ticklabel numbers in
scientific notation.
Jon
On Tue, 2010年10月19日 at 21:41 +0200, Friedrich Romstedt wrote:
> 2010年10月19日 David Pine <dj...@gm...>:
> > I like the times symbol but others prefer the dot (which I missed in the gmane preview!). So I like your suggestion of providing an option to use either \cdot or \times.
> 
> Okay, I'll try to look into it next week, is that okay with you both?
> I don't want to do it now since there might be more under the hood,
> just thinking about automatic exponent choice, I have a module for
> that, but it needs to pick up all the range the formatter spans over.
> 
> I'd say we also have use for three other configs of the exponent choice:
> a) largest
> b) smallest
> c) mean
> d) dynamic
> exponent.
> 
> Examples:
> (a) 0.001 10^2 ... 2.0 10^2
> (b) 1.0 10^-1 ... 200.0 10^-1
> (c) 0.01 10^1 ... 20.0 10^1
> (d) 1.0 10^-1 ... 2.0 10^2
> Sorry if there's some mistake but you see the principle.
> 
> Also the number of digits present need to be configurable ... enough for a week.
> 
> I favour (c) as the default, and 2 digits precision.
> 
> Friedrich
-- 
______________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
js...@cf... 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
 cell: (781) 363-0035 USA
______________________________________________________________
From: Friedrich R. <fri...@gm...> - 2010年10月19日 19:50:24
2010年10月19日 Jonathan Slavin <js...@cf...>:
> I think that'd be fine -- i.e. the option of \cdot or \times (though in
> the gmane preview the dot looks a bit low). In the mean time, I came up
> with the method below that worked for my purpose.
Okay thx
> import matplotlib.pyplot as plt
> import numpy as np
> from matplotlib.ticker import FuncFormatter
>
> def scinot(x,pos=None):
>  if x == 0:
>    s = '0'
>  else:
>    xp = int(np.floor(np.log10(np.abs(x))))
>    mn = x/10.**xp
>    # Here we truncate to 2 significant digits -- may not be enough
>    # in all cases
>    s = '$'+str('%.1f'%mn) +'\\times 10^{'+str(xp)+'}$'
>  return s
>
> x = np.linspace(0.,2.,10)*1.E18
> y = 2.*(x/1.E18) - 1.
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(x,y)
> ax.xaxis.set_major_formatter(FucFormatter(scinot))
typo for the records although abvious: FuncFormatter
> plt.show()
Okay I can do the tedious work of changing my code ASAP but with low
priority ...
Friedrich
From: Jonathan S. <js...@cf...> - 2010年10月19日 19:42:47
I think that'd be fine -- i.e. the option of \cdot or \times (though in
the gmane preview the dot looks a bit low). In the mean time, I came up
with the method below that worked for my purpose.
Jon
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FuncFormatter
def scinot(x,pos=None):
 if x == 0:
 s = '0'
 else:
 xp = int(np.floor(np.log10(np.abs(x))))
 mn = x/10.**xp
 # Here we truncate to 2 significant digits -- may not be enough 
 # in all cases
 s = '$'+str('%.1f'%mn) +'\\times 10^{'+str(xp)+'}$'
 return s
x = np.linspace(0.,2.,10)*1.E18
y = 2.*(x/1.E18) - 1.
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.xaxis.set_major_formatter(FucFormatter(scinot))
plt.show()
On Tue, 2010年10月19日 at 15:30 -0400, David Pine wrote:
> I like the times symbol but others prefer the dot (which I missed in the gmane preview!). So I like your suggestion of providing an option to use either \cdot or \times.
> 
> David
> 
> On Oct 19, 2010, at 3:23 PM, Friedrich Romstedt wrote:
> 
> > What about inserting \cdot, that's the scientific notation I do prefer?
> > 
> > If I'm not mistaken that's what I did that time, might be unreadable
> > in the preview? I checked, when you look close you see the dot in
> > gmane preview.
> > 
> > We can make this customisable, with \times as an alternative option.
> > 
> > Friedrich
> 
-- 
______________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
js...@cf... 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
 cell: (781) 363-0035 USA
______________________________________________________________
From: Friedrich R. <fri...@gm...> - 2010年10月19日 19:41:35
2010年10月19日 David Pine <dj...@gm...>:
> I like the times symbol but others prefer the dot (which I missed in the gmane preview!). So I like your suggestion of providing an option to use either \cdot or \times.
Okay, I'll try to look into it next week, is that okay with you both?
I don't want to do it now since there might be more under the hood,
just thinking about automatic exponent choice, I have a module for
that, but it needs to pick up all the range the formatter spans over.
I'd say we also have use for three other configs of the exponent choice:
a) largest
b) smallest
c) mean
d) dynamic
exponent.
Examples:
(a) 0.001 10^2 ... 2.0 10^2
(b) 1.0 10^-1 ... 200.0 10^-1
(c) 0.01 10^1 ... 20.0 10^1
(d) 1.0 10^-1 ... 2.0 10^2
Sorry if there's some mistake but you see the principle.
Also the number of digits present need to be configurable ... enough for a week.
I favour (c) as the default, and 2 digits precision.
Friedrich
2010年10月19日 Dharhas Pothina <Dha...@tw...>:
> I'm assuming this is possible and common but I'm not finding the correct combination of search terms to find any examples on the mailing list or online on how to do this.
>
> I'd like to display the y-axis tick labels in the 'comma' notation i.e.
>
> 234004 = 234,004
> 1237689 = 1,237,689
You could write your own formatter, don't be scared. The following
might be a good starting point:
http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.FuncFormatter
You just need to write a function inserting the comma into the
number's string repr() given a plain Python number.
If I'm not mistaken this feature has never been requested so far, AFAICT.
Just got Goekhan's message, try a combination of both, might be worth.
hthy,
Friedrich
From: David P. <dj...@gm...> - 2010年10月19日 19:30:37
I like the times symbol but others prefer the dot (which I missed in the gmane preview!). So I like your suggestion of providing an option to use either \cdot or \times.
David
On Oct 19, 2010, at 3:23 PM, Friedrich Romstedt wrote:
> What about inserting \cdot, that's the scientific notation I do prefer?
> 
> If I'm not mistaken that's what I did that time, might be unreadable
> in the preview? I checked, when you look close you see the dot in
> gmane preview.
> 
> We can make this customisable, with \times as an alternative option.
> 
> Friedrich
On Tue, Oct 19, 2010 at 1:31 PM, Dharhas Pothina
<Dha...@tw...> wrote:
> Hi All,
>
> I'm assuming this is possible and common but I'm not finding the correct combination of search terms to find any examples on the mailing list or online on how to do this.
>
> I'd like to display the y-axis tick labels in the 'comma' notation i.e.
>
> 234004 = 234,004
> 1237689 = 1,237,689
> etc
>
> thanks,
>
> - dharhas
>
Python 2.7 has format specifiers for thousands separation:
http://docs.python.org/dev/whatsnew/2.7.html#pep-378-format-specifier-for-thousands-separator
moneyfmt recipe http://docs.python.org/library/decimal.html#recipes
might provide an alternative solution. In any case you should need to
get yticklabels and set them with the converted values.
-- 
Gökhan
From: Friedrich R. <fri...@gm...> - 2010年10月19日 19:23:54
What about inserting \cdot, that's the scientific notation I do prefer?
If I'm not mistaken that's what I did that time, might be unreadable
in the preview? I checked, when you look close you see the dot in
gmane preview.
We can make this customisable, with \times as an alternative option.
Friedrich
Hi All,
I'm assuming this is possible and common but I'm not finding the correct combination of search terms to find any examples on the mailing list or online on how to do this.
I'd like to display the y-axis tick labels in the 'comma' notation i.e.
234004 = 234,004
1237689 = 1,237,689
etc
thanks,
- dharhas
From: David P. <dj...@gm...> - 2010年10月19日 18:46:18
I agree with Jonathan and would very much like to see this feature implemented. The example shown in the thread didn't show the "×ばつ" symbol, however, which would be nice to have -- e.g. it should read 2.0 ×ばつ 102 rather than 2.0 102.
David
On Oct 19, 2010, at 1:08 PM, Friedrich Romstedt wrote:
> 2010年10月18日 Jonathan Slavin <js...@cf...>:
>> I'm wondering if there's some relatively automatic way to have the
>> ticklabels to come out in scientific notation for an axis that uses a
>> linear scale (and has a range that warrants scientific notation)? For
>> example, an axis that goes from 0 to 2.E18 by default uses the labels 0,
>> 0.5, 1.0, 1.5, 2.0 and puts 1e18 at the end of the axis. To me this is
>> unappealing. 1e18 is a computer programming way to write the 10^{18} (in
>> LaTeX formatting). In IDL the ticklabels are 5.0x10^{17}, 1.0x10^{18},
>> 1.5x10^{18}, 2.0x10^{18}. This is one instance where I think IDL gets
>> it right and matplotlib gets it wrong. So, as far as I can tell, one
>> can give the ticklabels by hand, and so I could achieve my desired
>> labels that way, but it'd be nice to have a more automatic way to do it.
>> Searching the examples, I've come up empty so far. I would also
>> advocate changing the default format for labeling axes that fall in this
>> category. Do the developers have any opinions on this?
> 
> There's a thread some monthes ago about this, I provided code to do
> this. Currently, this Formatter class didn't make it into matplotlib
> due a lack of providing a patch by me. If others agree that this
> would be a good feature, I'll clean the code if necessary and provide
> another patch for this.
> 
> Looking for the thread ...
> http://article.gmane.org/gmane.comp.python.matplotlib.general/23824/match=scientific+notation+friedrich
> 
> IIRC, the formatter class does NOT provide automatic choice of
> appropriate exponent, i.e. you have to provide this in instantiation
> time.
> 
> hth, and let me know about any progress,
> Friedrich
> 
> P.S.: I just gave the thread link and didn't look into it further.
> But it should be the message I remembered.
> 
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Paul H. <pmh...@gm...> - 2010年10月19日 18:19:07
Use the legend method of your axes object:
http://matplotlib.sourceforge.net/examples/api/legend_demo.html?highlight=codex%20legend
On Tue, Oct 19, 2010 at 11:15 AM, Waléria Antunes David
<wal...@gm...> wrote:
> Hi,
>
> This example helped me. I have another question. How do I insert the label
> as in the example image?: Data from Riess et al (2004)
>
> Thanks,
> Waleria.
>
> On Tue, Oct 19, 2010 at 3:50 PM, Paul Hobson <pmh...@gm...> wrote:
>>
>> Waléria,
>>
>> Hopefully this example helps:
>>
>> # code...
>> import matplotlib.pyplot as plt
>> fig = plt.figure()
>> ax = fig.add_subplot(111)
>> ax.plot([0,1,2], [0,1,3], 'ko')
>>
>> # set the xticks manually
>> ax.set_xticks([0,0.5,1.0,1.5,2])
>>
>> # set the yticks using "range"
>> ytix = range(6)
>> ax.set_yticks(ytix)
>> plt.show()
>> #...done
>>
>> --paul
>>
>>
>>
>>
>>
>> On Tue, Oct 19, 2010 at 10:15 AM, Waléria Antunes David
>> <wal...@gm...> wrote:
>> > Hi all,
>> >
>> > I have a graph. I plotted using python, matplotlib. And i have an
>> > example.
>> >
>> > I need to let the x-axis of my graph, and how do I change plt.ylabel
>> > ('Y',
>> > size = 10) as the example.
>> >
>> > Example: In my graph, the x-axis this way: 0.0 ----- 0.2 ------ 0.4
>> > -----
>> > 0.6 ------- 0.8 ------- 1.0 ------- 1.2 -------- 1.4
>> > I need this way: 0 ----- 0.5 ------ 1.0 ----- 1.5 -------- 2
>> >
>> > My code: http://pastebin.com/GZqWKwZf
>> >
>> > Can you help me?
>> >
>> > Thanks
>> > Waleria
>> >
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Download new Adobe(R) Flash(R) Builder(TM) 4
>> > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> > Flex(R) Builder(TM)) enable the development of rich applications that
>> > run
>> > across multiple browsers and platforms. Download your free trials today!
>> > http://p.sf.net/sfu/adobe-dev2dev
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Mat...@li...
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> >
>> >
>
>
From: Waléria A. D. <wal...@gm...> - 2010年10月19日 18:15:42
Hi,
This example helped me. I have another question. How do I insert the label
as in the example image?: Data from Riess et al (2004)
Thanks,
Waleria.
On Tue, Oct 19, 2010 at 3:50 PM, Paul Hobson <pmh...@gm...> wrote:
> Waléria,
>
> Hopefully this example helps:
>
> # code...
> import matplotlib.pyplot as plt
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot([0,1,2], [0,1,3], 'ko')
>
> # set the xticks manually
> ax.set_xticks([0,0.5,1.0,1.5,2])
>
> # set the yticks using "range"
> ytix = range(6)
> ax.set_yticks(ytix)
> plt.show()
> #...done
>
> --paul
>
>
>
>
>
> On Tue, Oct 19, 2010 at 10:15 AM, Waléria Antunes David
> <wal...@gm...> wrote:
> > Hi all,
> >
> > I have a graph. I plotted using python, matplotlib. And i have an
> example.
> >
> > I need to let the x-axis of my graph, and how do I change plt.ylabel
> ('Y',
> > size = 10) as the example.
> >
> > Example: In my graph, the x-axis this way: 0.0 ----- 0.2 ------ 0.4 -----
> > 0.6 ------- 0.8 ------- 1.0 ------- 1.2 -------- 1.4
> > I need this way: 0 ----- 0.5 ------ 1.0 ----- 1.5 -------- 2
> >
> > My code: http://pastebin.com/GZqWKwZf
> >
> > Can you help me?
> >
> > Thanks
> > Waleria
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Download new Adobe(R) Flash(R) Builder(TM) 4
> > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> > Flex(R) Builder(TM)) enable the development of rich applications that run
> > across multiple browsers and platforms. Download your free trials today!
> > http://p.sf.net/sfu/adobe-dev2dev
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
From: Justin M. <jn...@gm...> - 2010年10月19日 18:14:55
On Fri, Oct 8, 2010 at 11:10 PM, Jae-Joon Lee <lee...@gm...> wrote:
> The label_mode need to be capital "L", instead of "l". I guess this
> will fix your first problem.
> While we make "l" same as "L", but I think it actually degrade the
> readability of the code, and I;m inclined to leave it as is. Let me
> know if you have any suggestions though.
Sorry for the delayed response, but I've been trying to think of a
decent suggestion.
The capital "L" fixed the problem with the extra xticks. I had
completely misread it; I was trying to label the lower-left axes only
with a lower-case "L" ("l") and really needed a one ("1").
How about "bottom" instead of "L", and "lower left" instead of "1"?
You might consider using the "bottom", "lower left", "top", ...
pattern if you want to support other locations.
 Justin
From: Friedrich R. <fri...@gm...> - 2010年10月19日 17:51:16
2010年10月19日 Waléria Antunes David <wal...@gm...>:
> Example: In my graph, the x-axis this way: 0.0 ----- 0.2 ------ 0.4 -----
> 0.6 ------- 0.8 ------- 1.0 ------- 1.2 -------- 1.4
> I need this way: 0 ----- 0.5 ------ 1.0 ----- 1.5 -------- 2
you might use mpl.ticker.MaxNLocator(4).
Install it in the Axes using
ax.set_major_locator(mpl.ticker.MaxNLocator(4, steps=[1, 2, 5, 10])).
The number is the maximum number of bins. *steps* are the allowed
steps by which to step between bin boundaries. See the docs (module
mpl.ticker) for details!
Friedrich
From: Friedrich R. <fri...@gm...> - 2010年10月19日 17:44:00
Attachments: mpl-test.txt
Hi,
please, can someone dealing with the path simplication have a look at
the log attached?
I'm on 10.6 Mac OS X with astraw repo 10/18/2010.
The symlog mismatch is said to by fixed; for the pcolormesh mismatch I
cannot see any visual difference. Might by false alarm. But the
``len(simplified)`` things might be worth being considered I guess. I
have numpy.__version__ 1.4.1. The python running the tests is 32bit
(although compiled fat). Python 2.6. mpl compiled locally of course
by the fat Python, so both archs. gcc-4.2 on 10.6 as usual. ...
Friedrich
From: Friedrich R. <fri...@gm...> - 2010年10月19日 17:27:15
2010年10月19日 Kynn Jones <ky...@gm...>:
> I need to generate a fairly complex chart, for which I need the ability to
> specify not only subplots, but also sub-subplots. (Our group has found such
> charts useful in the past, but they were generated using horrific MATLAB
> code, which we're trying to get away from as quickly as we can, not only
> because the code is impenetrable, but because the MATLAB GUI is unstable,
> and produces very poor results when we try to print the charts.)
> I'll try to describe what I want to do in a bit more detail (it's messy).
> First imagine a simple plot (just a simple X-Y line graph connecting 3-4
> datapoints). I'll call this a level-0 plot. Now, join ~10 of these level-0
> plots side-by-side (with no space between the plots). This new aggregate is
> a level-1 plot. Next stack ~10 level-1 plots vertically, again, with no
> space between them. The resulting aggregate is a level-2 plot. Finally
> arrange ~10 of these level-2 plots side-by-side, with some spacing between
> them. The desired final product is this level-3 plot.
> (In practice, the numbers of elements within each aggregate is not exactly
> 10. For example, for my immediate application the numbers would be 8
> level-0 plots per level-1 plot; 17 level-1 plots per level-2 plot; and 8
> level-2 plots per level-3 plot. The level-0 plots should have an aspect
> ratio (H:W) of 4. Therefore, the level-2 plots will have an aspect ratio of
> almost 8.)
> How can I achieve this?
My idea would be to add another layer. Meaning to provide a class
which *creates* Axes, and which has other instances of *this class* in
an attribute. The attrib would be scalar. Repetition is done via
recursive call so some privat e method, initiated by a call to a
public commit method. So you would do in pseudo-code:
level0 = LevelAxesGenerator() # NOT actually creating the Axes, see below.
level1 = LevelAxesGenerator(leaf=level0, repeat=10, direction='x') #
NOT creating too.
level1.create(width=foo, height=bar) # Subdividing automatically,
generating Axes in the recursive calls on level0-level
This shouldn't be super-hard.
Sorry, I cannot help you with implementation currently.
When you code it, think about general usability, also for other users,
if you're inclined. I would maybe have been such a user in the past.
``.create()`` could maybe called ``.commit()``, this is more specific.
 Create can mean anything.
You could even add a .populate() method, so that you can derive from
``LevelAxesGenerator`` and the instances automatically populate their
axes based on the "coordinate" tuple (level0, level1, level2, ...).
This would be really neat, and it's not too specific, because it'll be
the main use of this level-functionality.
Success,
Friedrich
From: Friedrich R. <fri...@gm...> - 2010年10月19日 17:08:13
2010年10月18日 Jonathan Slavin <js...@cf...>:
> I'm wondering if there's some relatively automatic way to have the
> ticklabels to come out in scientific notation for an axis that uses a
> linear scale (and has a range that warrants scientific notation)? For
> example, an axis that goes from 0 to 2.E18 by default uses the labels 0,
> 0.5, 1.0, 1.5, 2.0 and puts 1e18 at the end of the axis. To me this is
> unappealing. 1e18 is a computer programming way to write the 10^{18} (in
> LaTeX formatting). In IDL the ticklabels are 5.0x10^{17}, 1.0x10^{18},
> 1.5x10^{18}, 2.0x10^{18}. This is one instance where I think IDL gets
> it right and matplotlib gets it wrong. So, as far as I can tell, one
> can give the ticklabels by hand, and so I could achieve my desired
> labels that way, but it'd be nice to have a more automatic way to do it.
> Searching the examples, I've come up empty so far. I would also
> advocate changing the default format for labeling axes that fall in this
> category. Do the developers have any opinions on this?
There's a thread some monthes ago about this, I provided code to do
this. Currently, this Formatter class didn't make it into matplotlib
due a lack of providing a patch by me. If others agree that this
would be a good feature, I'll clean the code if necessary and provide
another patch for this.
Looking for the thread ...
http://article.gmane.org/gmane.comp.python.matplotlib.general/23824/match=scientific+notation+friedrich
IIRC, the formatter class does NOT provide automatic choice of
appropriate exponent, i.e. you have to provide this in instantiation
time.
hth, and let me know about any progress,
Friedrich
P.S.: I just gave the thread link and didn't look into it further.
But it should be the message I remembered.
From: vaishu <vai...@gm...> - 2010年10月19日 15:44:20
Hey guys,
I am a new user to the python & matplotlib, this might be a simple question
but I searched the internet for hours and couldn't find a solution for this.
I am plotting precipitation data from which is in the NetCDF format. What I
find weird is that, the data doesn't have any negative values in it.(I
checked that many times,just to make sure). But the value in the colorbar
starts with a negative value (like -0.0000312 etc). It doesnt make sense
because I dont do any manipulations to the data, other that just selecting a
part of the data from the big file and plotting it.
So my code doesn't much to it. Here is the code:
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset
cd progs
f=Dataset('V21_GPCP.1979-2009.nc')
lats=f.variables['lat'][:]
lons=f.variables['lon'][:]
prec=f.variables['PREC'][:]
la=lats[31:52]
lo=lons[18:83]
pre=prec[0,31:52,18:83]
m = Basemap(width=06.e6,height=05.e6,projection='gnom',lat_0=15.,lon_0=80.)
x, y = m(*np.meshgrid(lo,la))
m.drawcoastlines()
m.drawmapboundary(fill_color='lightblue')
m.drawparallels(np.arange(-90.,120.,5.),labels=[1,0,0,0])
m.drawmeridians(np.arange(0.,420.,5.),labels=[0,0,0,1])
cs=m.contourf(x,y,pre,50,cmap=plt.cm.jet)
plt.colorbar()
The output that I got for that code was a beautiful plot, with the colorbar
starting from the value -0.00001893, and the rest are positive values, and I
believe are correct. Its just the minimum value thats bugging me.
http://old.nabble.com/file/p30001558/jan1979plot.png 
I would like to know:
Is there anything wrong in my code? cos I know that the data is right.
Is there a way to manually change the value to 0?
Is it right for the values in the colorbar to change everytime we run the
code, cos for the same data, the next time I run the code, the values go
like this " -0.00001893, 2.00000000, 4.00000000, 6.00000000 etc"
I want to customize them to "0.0, 2.0, 4.0, 6.0 etc"
Thanks, 
Vaishu
-- 
View this message in context: http://old.nabble.com/weird-range-value-in-the-colorbar%2C-matplotlib-tp30001558p30001558.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Gökhan S. <gok...@gm...> - 2010年10月19日 15:24:09
OK, I have just done an "svn up" and seen that this is fixed in
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib?revision=8756&view=revision
Thanks for the fix.
On Tue, Oct 19, 2010 at 10:06 AM, Gökhan Sever <gok...@gm...> wrote:
> Sorry I have forgotten to add that you should issue a "k" key on the
> plot to scale the x-axis logarithmically.
>
> On Tue, Oct 19, 2010 at 7:42 AM, Michael Droettboom <md...@st...> wrote:
>> I can't reproduce this here with trunk, though I get a different crash
>> in the 1.x branch (which has an easy fix). Are there any additional
>> steps required to reproduce?
>>
>> Mike
>>
>> On 10/18/2010 09:50 PM, Gökhan Sever wrote:
>>> Hello,
>>>
>>> I can't log scale my axes on rev8753. It was working on a previous
>>> check-out (possibly a month old). Using WXagg, but same as with
>>> Qt4Agg.
>>>
>>> Any ideas what could be wrong in the trunk? It seems to me that some
>>> recent changes on LogLocator [
>>> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/ticker.py?view=log
>>> ]class causing this.
>>>
>>> I[5]: d_um_pcasp_midpoint
>>> O[5]:
>>> array([ 0.124 , 0.1485, 0.179 , 0.2145, 0.2585, 0.333 , 0.5195,
>>>     0.7955, 1.15 , 1.7805, 2.437 , 2.7865, 3.187 , 3.991 ,
>>>     4.957 ])
>>>
>>> I[6]: pcasp_spectral_density09d
>>> O[6]:
>>> array([ 523.31751809, 200.73229115, 179.82563138, 183.13125583,
>>>     160.62733458,  48.77147359,  22.23106603,  7.56501192,
>>>      10.94637257,  8.47475684,  21.53335341,  32.950845 ,
>>>      30.502102 ,  28.90555459,  21.38636076])
>>>
>>> I[7]: plt.plot(d_um_pcasp_midpoint, pcasp_spectral_density09d)
>>> O[7]: [<matplotlib.lines.Line2D object at 0x14b2474c>]
>>>
>>> I[8]: ERROR: An unexpected error occurred while tokenizing input
>>> The following traceback may be corrupted or invalid
>>> The error message is: ('EOF in multi-line statement', (554, 0))
>>>
>>> ERROR: An unexpected error occurred while tokenizing input
>>> The following traceback may be corrupted or invalid
>>> The error message is: ('EOF in multi-line statement', (555, 0))
>>>
>>> ERROR: An unexpected error occurred while tokenizing input
>>> The following traceback may be corrupted or invalid
>>> The error message is: ('EOF in multi-line statement', (555, 0))
>>>
>>> ERROR: An unexpected error occurred while tokenizing input
>>> The following traceback may be corrupted or invalid
>>> The error message is: ('EOF in multi-line statement', (555, 0))
>>>
>>> ---------------------------------------------------------------------------
>>> ValueError                Traceback (most recent call last)
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_wx.pyc
>>> in _onKeyDown(self, evt)
>>>   1254     key = self._get_key(evt)
>>>   1255     evt.Skip()
>>> -> 1256     FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
>>>   1257
>>>   1258   def _onKeyUp(self, evt):
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backend_bases.pyc
>>> in key_press_event(self, key, guiEvent)
>>>   1525     s = 'key_press_event'
>>>   1526     event = KeyEvent(s, self, key, self._lastx,
>>> self._lasty, guiEvent=guiEvent)
>>> -> 1527     self.callbacks.process(s, event)
>>>   1528
>>>   1529   def key_release_event(self, key, guiEvent=None):
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/cbook.pyc
>>> in process(self, s, *args, **kwargs)
>>>   260         del self.callbacks[s][cid]
>>>   261       else:
>>> --> 262         proxy(*args, **kwargs)
>>>   263
>>>   264
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/cbook.pyc
>>> in __call__(self, *args, **kwargs)
>>>   186         mtd = self.func
>>>   187       # invoke the callable and return the result
>>>
>>> --> 188       return mtd(*args, **kwargs)
>>>   189
>>>   190     def __eq__(self, other):
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backend_bases.pyc
>>> in key_press(self, event)
>>>   2254       elif scalex == 'linear':
>>>   2255         ax.set_xscale('log')
>>> -> 2256         ax.figure.canvas.draw()
>>>   2257
>>>   2258     elif (event.key.isdigit() and event.key!='0') or
>>> event.key in all:
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_wxagg.pyc
>>> in draw(self, drawDC)
>>>    57     """
>>>    58     DEBUG_MSG("draw()", 1, self)
>>> ---> 59     FigureCanvasAgg.draw(self)
>>>    60
>>>    61     self.bitmap =
>>> _convert_agg_to_wx_bitmap(self.get_renderer(), None)
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
>>> in draw(self)
>>>   392
>>>   393     self.renderer = self.get_renderer()
>>> --> 394     self.figure.draw(self.renderer)
>>>   395
>>>   396   def get_renderer(self):
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
>>> in draw_wrapper(artist, renderer, *args, **kwargs)
>>>    53   def draw_wrapper(artist, renderer, *args, **kwargs):
>>>    54     before(artist, renderer)
>>> ---> 55     draw(artist, renderer, *args, **kwargs)
>>>    56     after(artist, renderer)
>>>    57
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/figure.pyc
>>> in draw(self, renderer)
>>>   872     dsu.sort(key=itemgetter(0))
>>>   873     for zorder, func, args in dsu:
>>> --> 874       func(*args)
>>>   875
>>>   876     renderer.close_group('figure')
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
>>> in draw_wrapper(artist, renderer, *args, **kwargs)
>>>    53   def draw_wrapper(artist, renderer, *args, **kwargs):
>>>    54     before(artist, renderer)
>>> ---> 55     draw(artist, renderer, *args, **kwargs)
>>>    56     after(artist, renderer)
>>>    57
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axes.pyc in
>>> draw(self, renderer, inframe)
>>>   1952
>>>   1953     for zorder, a in dsu:
>>> -> 1954       a.draw(renderer)
>>>   1955
>>>   1956     renderer.close_group('axes')
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
>>> in draw_wrapper(artist, renderer, *args, **kwargs)
>>>    53   def draw_wrapper(artist, renderer, *args, **kwargs):
>>>    54     before(artist, renderer)
>>> ---> 55     draw(artist, renderer, *args, **kwargs)
>>>    56     after(artist, renderer)
>>>    57
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
>>> draw(self, renderer, *args, **kwargs)
>>>   938     renderer.open_group(__name__)
>>>   939     interval = self.get_view_interval()
>>> --> 940     tick_tups = [ t for t in self.iter_ticks()]
>>>   941     if self._smart_bounds:
>>>   942       # handle inverted limits
>>>
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
>>> iter_ticks(self)
>>>   874     majorTicks = self.get_major_ticks(len(majorLocs))
>>>   875     self.major.formatter.set_locs(majorLocs)
>>> --> 876     majorLabels = [self.major.formatter(val, i) for i, val
>>> in enumerate(majorLocs)]
>>>   877
>>>   878     minorLocs = self.minor.locator()
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
>>> in __call__(self, x, pos)
>>>   635     sign = np.sign(x)
>>>   636     fx = math.log(abs(x))/math.log(b)
>>> --> 637     isDecade = is_decade(fx)
>>>   638
>>>   639     usetex = rcParams['text.usetex']
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
>>> in is_decade(x, base)
>>>   1190     return True
>>>   1191   lx = np.log(x)/np.log(base)
>>> -> 1192   return abs(lx - nearest_long(lx))< 1e-10
>>>   1193
>>>   1194 class LogLocator(Locator):
>>>
>>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
>>> in nearest_long(x)
>>>   1184   if x == 0: return 0L
>>>   1185   elif x> 0: return long(x+0.5)
>>> -> 1186   else: return long(x-0.5)
>>>   1187
>>>   1188 def is_decade(x, base=10):
>>>
>>> ValueError: cannot convert float NaN to integer
>>>
>>>
>>>
>>
>>
>> --
>> Michael Droettboom
>> Science Software Branch
>> Space Telescope Science Institute
>> Baltimore, Maryland, USA
>>
>>
>> ------------------------------------------------------------------------------
>> Download new Adobe(R) Flash(R) Builder(TM) 4
>> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> Flex(R) Builder(TM)) enable the development of rich applications that run
>> across multiple browsers and platforms. Download your free trials today!
>> http://p.sf.net/sfu/adobe-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
>
> --
> Gökhan
>
-- 
Gökhan
From: Gökhan S. <gok...@gm...> - 2010年10月19日 15:06:57
Sorry I have forgotten to add that you should issue a "k" key on the
plot to scale the x-axis logarithmically.
On Tue, Oct 19, 2010 at 7:42 AM, Michael Droettboom <md...@st...> wrote:
> I can't reproduce this here with trunk, though I get a different crash
> in the 1.x branch (which has an easy fix). Are there any additional
> steps required to reproduce?
>
> Mike
>
> On 10/18/2010 09:50 PM, Gökhan Sever wrote:
>> Hello,
>>
>> I can't log scale my axes on rev8753. It was working on a previous
>> check-out (possibly a month old). Using WXagg, but same as with
>> Qt4Agg.
>>
>> Any ideas what could be wrong in the trunk? It seems to me that some
>> recent changes on LogLocator [
>> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/ticker.py?view=log
>> ]class causing this.
>>
>> I[5]: d_um_pcasp_midpoint
>> O[5]:
>> array([ 0.124 , 0.1485, 0.179 , 0.2145, 0.2585, 0.333 , 0.5195,
>>     0.7955, 1.15 , 1.7805, 2.437 , 2.7865, 3.187 , 3.991 ,
>>     4.957 ])
>>
>> I[6]: pcasp_spectral_density09d
>> O[6]:
>> array([ 523.31751809, 200.73229115, 179.82563138, 183.13125583,
>>     160.62733458,  48.77147359,  22.23106603,  7.56501192,
>>      10.94637257,  8.47475684,  21.53335341,  32.950845 ,
>>      30.502102 ,  28.90555459,  21.38636076])
>>
>> I[7]: plt.plot(d_um_pcasp_midpoint, pcasp_spectral_density09d)
>> O[7]: [<matplotlib.lines.Line2D object at 0x14b2474c>]
>>
>> I[8]: ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (554, 0))
>>
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (555, 0))
>>
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (555, 0))
>>
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (555, 0))
>>
>> ---------------------------------------------------------------------------
>> ValueError                Traceback (most recent call last)
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_wx.pyc
>> in _onKeyDown(self, evt)
>>   1254     key = self._get_key(evt)
>>   1255     evt.Skip()
>> -> 1256     FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
>>   1257
>>   1258   def _onKeyUp(self, evt):
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backend_bases.pyc
>> in key_press_event(self, key, guiEvent)
>>   1525     s = 'key_press_event'
>>   1526     event = KeyEvent(s, self, key, self._lastx,
>> self._lasty, guiEvent=guiEvent)
>> -> 1527     self.callbacks.process(s, event)
>>   1528
>>   1529   def key_release_event(self, key, guiEvent=None):
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/cbook.pyc
>> in process(self, s, *args, **kwargs)
>>   260         del self.callbacks[s][cid]
>>   261       else:
>> --> 262         proxy(*args, **kwargs)
>>   263
>>   264
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/cbook.pyc
>> in __call__(self, *args, **kwargs)
>>   186         mtd = self.func
>>   187       # invoke the callable and return the result
>>
>> --> 188       return mtd(*args, **kwargs)
>>   189
>>   190     def __eq__(self, other):
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backend_bases.pyc
>> in key_press(self, event)
>>   2254       elif scalex == 'linear':
>>   2255         ax.set_xscale('log')
>> -> 2256         ax.figure.canvas.draw()
>>   2257
>>   2258     elif (event.key.isdigit() and event.key!='0') or
>> event.key in all:
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_wxagg.pyc
>> in draw(self, drawDC)
>>    57     """
>>    58     DEBUG_MSG("draw()", 1, self)
>> ---> 59     FigureCanvasAgg.draw(self)
>>    60
>>    61     self.bitmap =
>> _convert_agg_to_wx_bitmap(self.get_renderer(), None)
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
>> in draw(self)
>>   392
>>   393     self.renderer = self.get_renderer()
>> --> 394     self.figure.draw(self.renderer)
>>   395
>>   396   def get_renderer(self):
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
>> in draw_wrapper(artist, renderer, *args, **kwargs)
>>    53   def draw_wrapper(artist, renderer, *args, **kwargs):
>>    54     before(artist, renderer)
>> ---> 55     draw(artist, renderer, *args, **kwargs)
>>    56     after(artist, renderer)
>>    57
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/figure.pyc
>> in draw(self, renderer)
>>   872     dsu.sort(key=itemgetter(0))
>>   873     for zorder, func, args in dsu:
>> --> 874       func(*args)
>>   875
>>   876     renderer.close_group('figure')
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
>> in draw_wrapper(artist, renderer, *args, **kwargs)
>>    53   def draw_wrapper(artist, renderer, *args, **kwargs):
>>    54     before(artist, renderer)
>> ---> 55     draw(artist, renderer, *args, **kwargs)
>>    56     after(artist, renderer)
>>    57
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axes.pyc in
>> draw(self, renderer, inframe)
>>   1952
>>   1953     for zorder, a in dsu:
>> -> 1954       a.draw(renderer)
>>   1955
>>   1956     renderer.close_group('axes')
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
>> in draw_wrapper(artist, renderer, *args, **kwargs)
>>    53   def draw_wrapper(artist, renderer, *args, **kwargs):
>>    54     before(artist, renderer)
>> ---> 55     draw(artist, renderer, *args, **kwargs)
>>    56     after(artist, renderer)
>>    57
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
>> draw(self, renderer, *args, **kwargs)
>>   938     renderer.open_group(__name__)
>>   939     interval = self.get_view_interval()
>> --> 940     tick_tups = [ t for t in self.iter_ticks()]
>>   941     if self._smart_bounds:
>>   942       # handle inverted limits
>>
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
>> iter_ticks(self)
>>   874     majorTicks = self.get_major_ticks(len(majorLocs))
>>   875     self.major.formatter.set_locs(majorLocs)
>> --> 876     majorLabels = [self.major.formatter(val, i) for i, val
>> in enumerate(majorLocs)]
>>   877
>>   878     minorLocs = self.minor.locator()
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
>> in __call__(self, x, pos)
>>   635     sign = np.sign(x)
>>   636     fx = math.log(abs(x))/math.log(b)
>> --> 637     isDecade = is_decade(fx)
>>   638
>>   639     usetex = rcParams['text.usetex']
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
>> in is_decade(x, base)
>>   1190     return True
>>   1191   lx = np.log(x)/np.log(base)
>> -> 1192   return abs(lx - nearest_long(lx))< 1e-10
>>   1193
>>   1194 class LogLocator(Locator):
>>
>> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
>> in nearest_long(x)
>>   1184   if x == 0: return 0L
>>   1185   elif x> 0: return long(x+0.5)
>> -> 1186   else: return long(x-0.5)
>>   1187
>>   1188 def is_decade(x, base=10):
>>
>> ValueError: cannot convert float NaN to integer
>>
>>
>>
>
>
> --
> Michael Droettboom
> Science Software Branch
> Space Telescope Science Institute
> Baltimore, Maryland, USA
>
>
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Gökhan
From: Michael D. <md...@st...> - 2010年10月19日 14:34:26
On 10/18/2010 05:17 PM, LittleBigBrain wrote:
> I ran the matplotlib.test() and got:
> FAILED (KNOWNFAIL=90, errors=14)
>
> I checked more carefully now. It turns out, all the differences are texts.
>
> Most of them are very small differences: Some of them offset to right
> and down a little bit. Some of them shrink a little bit. Maybe, it
> results from that some fonts in Windows are difference form Linux.
> 
We don't currently run a Windows-based buildbot for automated tests so 
we don't tend to catch these differences on a regular basis. The tests 
use the default fonts that ship with matplotlib, so there should be zero 
differences between Windows and other platforms (that is, at least, the 
goal). I'll have a look at these differences next time I'm in front of 
a Windows box.
> But there is one test gave out very big difference:
> the 'tests.test_axes.test_symlog'.
> The Y axis tick labels>10 are completely lost.
> Please check the attachments.
> 
Thanks for reporting this. This bug should now be fixed in SVN r8756 
(branch) and r8757 (trunk).
Mike
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Kynn J. <ky...@gm...> - 2010年10月19日 13:46:22
I need to generate a fairly complex chart, for which I need the ability to
specify not only subplots, but also sub-subplots. (Our group has found such
charts useful in the past, but they were generated using horrific MATLAB
code, which we're trying to get away from as quickly as we can, not only
because the code is impenetrable, but because the MATLAB GUI is unstable,
and produces very poor results when we try to print the charts.)
I'll try to describe what I want to do in a bit more detail (it's messy).
First imagine a simple plot (just a simple X-Y line graph connecting 3-4
datapoints). I'll call this a level-0 plot. Now, join ~10 of these level-0
plots side-by-side (with no space between the plots). This new aggregate is
a level-1 plot. Next stack ~10 level-1 plots vertically, again, with no
space between them. The resulting aggregate is a level-2 plot. Finally
arrange ~10 of these level-2 plots side-by-side, with some spacing between
them. The desired final product is this level-3 plot.
(In practice, the numbers of elements within each aggregate is not exactly
10. For example, for my immediate application the numbers would be 8
level-0 plots per level-1 plot; 17 level-1 plots per level-2 plot; and 8
level-2 plots per level-3 plot. The level-0 plots should have an aspect
ratio (H:W) of 4. Therefore, the level-2 plots will have an aspect ratio of
almost 8.)
How can I achieve this?
Thanks!
~kj
P.S. Without knowing much about the internals of matplotlib, it seems to me
that the best way to do this would be to define a container class that can
have itself as one of the contained elements. In this way, a containment
hierarchy of arbitrary depth could be defined. I understand that in matplot
lib Figure objects can contain Axes objects. Can they also contain other
Figure objects? If not, what would be required to enable this capability?
 Any comments or suggestions on what it would take to do this would be
appreciated.
From: Michael D. <md...@st...> - 2010年10月19日 12:42:43
I can't reproduce this here with trunk, though I get a different crash 
in the 1.x branch (which has an easy fix). Are there any additional 
steps required to reproduce?
Mike
On 10/18/2010 09:50 PM, Gökhan Sever wrote:
> Hello,
>
> I can't log scale my axes on rev8753. It was working on a previous
> check-out (possibly a month old). Using WXagg, but same as with
> Qt4Agg.
>
> Any ideas what could be wrong in the trunk? It seems to me that some
> recent changes on LogLocator [
> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/ticker.py?view=log
> ]class causing this.
>
> I[5]: d_um_pcasp_midpoint
> O[5]:
> array([ 0.124 , 0.1485, 0.179 , 0.2145, 0.2585, 0.333 , 0.5195,
> 0.7955, 1.15 , 1.7805, 2.437 , 2.7865, 3.187 , 3.991 ,
> 4.957 ])
>
> I[6]: pcasp_spectral_density09d
> O[6]:
> array([ 523.31751809, 200.73229115, 179.82563138, 183.13125583,
> 160.62733458, 48.77147359, 22.23106603, 7.56501192,
> 10.94637257, 8.47475684, 21.53335341, 32.950845 ,
> 30.502102 , 28.90555459, 21.38636076])
>
> I[7]: plt.plot(d_um_pcasp_midpoint, pcasp_spectral_density09d)
> O[7]: [<matplotlib.lines.Line2D object at 0x14b2474c>]
>
> I[8]: ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (554, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (555, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (555, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (555, 0))
>
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_wx.pyc
> in _onKeyDown(self, evt)
> 1254 key = self._get_key(evt)
> 1255 evt.Skip()
> -> 1256 FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
> 1257
> 1258 def _onKeyUp(self, evt):
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backend_bases.pyc
> in key_press_event(self, key, guiEvent)
> 1525 s = 'key_press_event'
> 1526 event = KeyEvent(s, self, key, self._lastx,
> self._lasty, guiEvent=guiEvent)
> -> 1527 self.callbacks.process(s, event)
> 1528
> 1529 def key_release_event(self, key, guiEvent=None):
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/cbook.pyc
> in process(self, s, *args, **kwargs)
> 260 del self.callbacks[s][cid]
> 261 else:
> --> 262 proxy(*args, **kwargs)
> 263
> 264
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/cbook.pyc
> in __call__(self, *args, **kwargs)
> 186 mtd = self.func
> 187 # invoke the callable and return the result
>
> --> 188 return mtd(*args, **kwargs)
> 189
> 190 def __eq__(self, other):
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backend_bases.pyc
> in key_press(self, event)
> 2254 elif scalex == 'linear':
> 2255 ax.set_xscale('log')
> -> 2256 ax.figure.canvas.draw()
> 2257
> 2258 elif (event.key.isdigit() and event.key!='0') or
> event.key in all:
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_wxagg.pyc
> in draw(self, drawDC)
> 57 """
> 58 DEBUG_MSG("draw()", 1, self)
> ---> 59 FigureCanvasAgg.draw(self)
> 60
> 61 self.bitmap =
> _convert_agg_to_wx_bitmap(self.get_renderer(), None)
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
> in draw(self)
> 392
> 393 self.renderer = self.get_renderer()
> --> 394 self.figure.draw(self.renderer)
> 395
> 396 def get_renderer(self):
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
> in draw_wrapper(artist, renderer, *args, **kwargs)
> 53 def draw_wrapper(artist, renderer, *args, **kwargs):
> 54 before(artist, renderer)
> ---> 55 draw(artist, renderer, *args, **kwargs)
> 56 after(artist, renderer)
> 57
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/figure.pyc
> in draw(self, renderer)
> 872 dsu.sort(key=itemgetter(0))
> 873 for zorder, func, args in dsu:
> --> 874 func(*args)
> 875
> 876 renderer.close_group('figure')
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
> in draw_wrapper(artist, renderer, *args, **kwargs)
> 53 def draw_wrapper(artist, renderer, *args, **kwargs):
> 54 before(artist, renderer)
> ---> 55 draw(artist, renderer, *args, **kwargs)
> 56 after(artist, renderer)
> 57
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axes.pyc in
> draw(self, renderer, inframe)
> 1952
> 1953 for zorder, a in dsu:
> -> 1954 a.draw(renderer)
> 1955
> 1956 renderer.close_group('axes')
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc
> in draw_wrapper(artist, renderer, *args, **kwargs)
> 53 def draw_wrapper(artist, renderer, *args, **kwargs):
> 54 before(artist, renderer)
> ---> 55 draw(artist, renderer, *args, **kwargs)
> 56 after(artist, renderer)
> 57
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
> draw(self, renderer, *args, **kwargs)
> 938 renderer.open_group(__name__)
> 939 interval = self.get_view_interval()
> --> 940 tick_tups = [ t for t in self.iter_ticks()]
> 941 if self._smart_bounds:
> 942 # handle inverted limits
>
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
> iter_ticks(self)
> 874 majorTicks = self.get_major_ticks(len(majorLocs))
> 875 self.major.formatter.set_locs(majorLocs)
> --> 876 majorLabels = [self.major.formatter(val, i) for i, val
> in enumerate(majorLocs)]
> 877
> 878 minorLocs = self.minor.locator()
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
> in __call__(self, x, pos)
> 635 sign = np.sign(x)
> 636 fx = math.log(abs(x))/math.log(b)
> --> 637 isDecade = is_decade(fx)
> 638
> 639 usetex = rcParams['text.usetex']
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
> in is_decade(x, base)
> 1190 return True
> 1191 lx = np.log(x)/np.log(base)
> -> 1192 return abs(lx - nearest_long(lx))< 1e-10
> 1193
> 1194 class LogLocator(Locator):
>
> /home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/ticker.pyc
> in nearest_long(x)
> 1184 if x == 0: return 0L
> 1185 elif x> 0: return long(x+0.5)
> -> 1186 else: return long(x-0.5)
> 1187
> 1188 def is_decade(x, base=10):
>
> ValueError: cannot convert float NaN to integer
>
>
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
1 message has been excluded from this view by a project administrator.

Showing results of 28

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