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





Showing results of 27

1 2 > >> (Page 1 of 2)
From: Eian V. <e....@sb...> - 2010年05月20日 22:59:58
Hi,
I would like a copy of matplotlib that is compatible with python 2.3. I searched all over the net and it is really difficult to find anything. Does anyone still have a copy? I believe it's version 0.87.3 or before.
Thank you,
Eian
From: João L. S. <js...@fc...> - 2010年05月20日 22:32:51
Jae-Joon Lee wrote:
> I cannot reproduce this error.
> I'm using r8330 on Linux.
> 
> I guess the error does not occur when you use a normal subplot?
> 
> Just in case, replace axes_grid with axes_grid1 and see if it makes
> any difference, i.e.,
> 
> from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost
> 
> Regards,
> 
> -JJ
> 
I've tried axes_grid1 and it works well. I'm using the default latex 
(Ubuntu 9.10)
latex --version
pdfTeX using libpoppler 3.141592-1.40.3-2.2 (Web2C 7.5.6)
[etc.]
Both the patches presented fixed the problem, thanks.
João Silva
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 19:34:21
On Mon, May 10, 2010 at 12:19 PM, Nico Schlömer
<nic...@gm...> wrote:
> When tick labels are explicitly supplied, that may not actually
> reflect in the return result of get_ticks. Specifically, I set the
> tick labels in a color bar, but get_ticklabels() returns a list of
> empty text objects Text(0,0,'').
> For regular axes, that seems to work better.
>
How did you set your ticklabels?
Again, matplotlib does not guarantee that all ticks that are returned
by get_ticks() will be actually drawn. On other words, get_ticks may
return ticks that are meaningless (and this is not a bug).
Also, colorbar axes works slightly differently from normal axes, but
I'm not sure if this is related with your problem.
As far as I can say, the use of get_ticks(), get_ticklabels() and etc
method should be limited to when you want to view/change their artist
attributes (like colors, etc.). You should not rely on this to
determine things like, whether some ticks will be drawn, locations of
ticks, and etc.
-JJ
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 19:19:12
On Thu, May 20, 2010 at 3:17 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Again, note that not all ticks that are returned by get_xticks()
> methods may be actually drawn.
>
I mean, even if their tick1On (and others) is True.
-JJ
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 19:17:39
Like the gridlines, these are determined during the drawing time.
Each tick instances have
tick1On
tick2On
label1On
label2On
attributes that controls whether to draw tick (or ticklabel) or not.
Again, note that not all ticks that are returned by get_xticks()
methods may be actually drawn.
-JJ
On Sat, May 8, 2010 at 4:36 AM, Nico Schlömer <nic...@gm...> wrote:
> Hi,
>
> say, is there a way to query an axis object whether or not the tick
> labels are drawn?
>
> I looked at -- one the x-axis -- get_xticks( and get_xticklabels()
> which in two different situations would spit out a list of doubles
> (the tick positions) and a list of text entries of the form
> Text(0,0,''). In one plot, though, the tick labels are drawn, not in
> the other one.
>
> Cheers,
> Nico
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 19:05:30
On Thu, May 13, 2010 at 11:25 PM, Uri Laserson <las...@mi...> wrote:
> I noticed that the example for the radar chart has only a single scale. Is
> there a way to generate a radar plot where each axis has its own scale?
Can you show us some example plots? I'm not clear what you want.
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 19:01:26
It turns out that when axes_grid toolkit is used and there are some
ticks does not have associated ticklabels (i.e., minor ticks), it
tries to call the "get_texts_widths_heights_descents" method with
empty string.
The following patch prevent this.
--- a/lib/mpl_toolkits/axisartist/axis_artist.py
+++ b/lib/mpl_toolkits/axisartist/axis_artist.py
@@ -769,6 +769,7 @@ class TickLabels(AxisLabel, AttributeCopier): # mtext.Text
 #self._set_offset_radius(r)
 for (x, y), a, l in self._locs_angles_labels:
+ if not l.strip(): continue
 self._set_ref_angle(a) #+ add_angle
 self.set_x(x)
 self.set_y(y)
@@ -811,6 +812,7 @@ class TickLabels(AxisLabel, AttributeCopier): # mtext.Text
 """
 whd_list = []
 for (x, y), a, l in self._locs_angles_labels:
+ if not l.strip(): continue
 clean_line, ismath = self.is_math_text(l)
 whd = renderer.get_text_width_height_descent(
 clean_line, self._fontproperties, ismath=ismath)
But it may be still safer to return 0,0,0 when empty string is given
for *get_texts_widths_heights_descents*?
Regards,
-JJ
On Thu, May 20, 2010 at 2:36 PM, Michael Droettboom <md...@st...> wrote:
> The following patch avoids the error with your attached plot. I'm sure
> if it the right fix though -- I'm not sure why empty strings are being
> sent this far along, and I'm also not seeing any ticks along the top.
>
> Mike
>
> Index: lib/matplotlib/texmanager.py
> ===================================================================
> --- lib/matplotlib/texmanager.py  (revision 8329)
> +++ lib/matplotlib/texmanager.py  (working copy)
> @@ -578,6 +578,9 @@
>     return width, heigth and descent of the text.
>     """
>
> +    if tex.strip() == '':
> +      return 0, 0, 0
> +
>     if renderer:
>       dpi_fraction = renderer.points_to_pixels(1.)
>     else:
>
>
> On 05/20/2010 02:11 PM, João Luís Silva wrote:
>> from matplotlib import rc
>> rc('text', usetex=True)
>>
>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>> import numpy as np
>> import matplotlib.pyplot as plt
>>
>> fig = plt.figure(1)
>> ax = SubplotHost(fig, 111)
>> fig.add_subplot(ax)
>> x = np.arange(1.0,10.0,0.1)
>> ax.semilogy(x,x**2)
>> plt.show()
>>
>
>
> --
> Michael Droettboom
> Science Software Branch
> Space Telescope Science Institute
> Baltimore, Maryland, USA
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 18:39:19
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot
use *markevery* keyword.
http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D.set_markevery
If you want more control, you can always draws the lines (without
markers) first and overplot markers in positions you want separately.
Regards,
-JJ
On Wed, May 19, 2010 at 11:56 AM, Omer Khalid <Ome...@ce...> wrote:
> Hi,
> I am a wondering if it's possible to have few line distinguishing marks on
> the data lines on a chart such as circle, start, square. When I use some
> thing like this for the color of the graph (i.e. rs, k^), it uses the shape
> for each data point and the lines becomes very thick. All I want is to put
> 4-5 shaper markers on each line with line (the data line will have few
> hundred data points).
> Many thanks,
> Omer
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Michael D. <md...@st...> - 2010年05月20日 18:38:27
The error may be dependent on the version of latex being used. Yours 
may be handling the empty content just fine. (I'm using TexLive 2009 on 
RHEL5).
Mike
On 05/20/2010 02:34 PM, Jae-Joon Lee wrote:
> I cannot reproduce this error.
> I'm using r8330 on Linux.
>
> I guess the error does not occur when you use a normal subplot?
>
> Just in case, replace axes_grid with axes_grid1 and see if it makes
> any difference, i.e.,
>
> from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost
>
> Regards,
>
> -JJ
>
>
> On Thu, May 20, 2010 at 2:11 PM, João Luís Silva<js...@fc...> wrote:
> 
>> Hi,
>>
>> I ran into a bug where I get the LaTeX error:
>>
>> RuntimeError: LaTeX was not able to process the following string:
>>
>> ''
>>
>> I know it's an uncommon plot, but I need extra (non-uniform) tick labels
>> at the top so I'm using SubplotHost, on a semilog plot with usetex (so
>> the fonts look similar to the ones on the paper).
>>
>> Matplotlib svn r8330 on Ubuntu 9.10.
>>
>> Regards,
>> João Silva
>>
>> Example script: -------------------------------------
>>
>> from matplotlib import rc
>> rc('text', usetex=True)
>>
>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>> import numpy as np
>> import matplotlib.pyplot as plt
>>
>> fig = plt.figure(1)
>> ax = SubplotHost(fig, 111)
>> fig.add_subplot(ax)
>> x = np.arange(1.0,10.0,0.1)
>> ax.semilogy(x,x**2)
>> plt.show()
>>
>> -------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> 
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Michael D. <md...@st...> - 2010年05月20日 18:36:26
The following patch avoids the error with your attached plot. I'm sure 
if it the right fix though -- I'm not sure why empty strings are being 
sent this far along, and I'm also not seeing any ticks along the top.
Mike
Index: lib/matplotlib/texmanager.py
===================================================================
--- lib/matplotlib/texmanager.py (revision 8329)
+++ lib/matplotlib/texmanager.py (working copy)
@@ -578,6 +578,9 @@
 return width, heigth and descent of the text.
 """
+ if tex.strip() == '':
+ return 0, 0, 0
+
 if renderer:
 dpi_fraction = renderer.points_to_pixels(1.)
 else:
On 05/20/2010 02:11 PM, João Luís Silva wrote:
> from matplotlib import rc
> rc('text', usetex=True)
>
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> import numpy as np
> import matplotlib.pyplot as plt
>
> fig = plt.figure(1)
> ax = SubplotHost(fig, 111)
> fig.add_subplot(ax)
> x = np.arange(1.0,10.0,0.1)
> ax.semilogy(x,x**2)
> plt.show()
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Jae-Joon L. <lee...@gm...> - 2010年05月20日 18:35:17
I cannot reproduce this error.
I'm using r8330 on Linux.
I guess the error does not occur when you use a normal subplot?
Just in case, replace axes_grid with axes_grid1 and see if it makes
any difference, i.e.,
from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost
Regards,
-JJ
On Thu, May 20, 2010 at 2:11 PM, João Luís Silva <js...@fc...> wrote:
> Hi,
>
> I ran into a bug where I get the LaTeX error:
>
> RuntimeError: LaTeX was not able to process the following string:
>
> ''
>
> I know it's an uncommon plot, but I need extra (non-uniform) tick labels
> at the top so I'm using SubplotHost, on a semilog plot with usetex (so
> the fonts look similar to the ones on the paper).
>
> Matplotlib svn r8330 on Ubuntu 9.10.
>
> Regards,
> João Silva
>
> Example script: -------------------------------------
>
> from matplotlib import rc
> rc('text', usetex=True)
>
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> import numpy as np
> import matplotlib.pyplot as plt
>
> fig = plt.figure(1)
> ax = SubplotHost(fig, 111)
> fig.add_subplot(ax)
> x = np.arange(1.0,10.0,0.1)
> ax.semilogy(x,x**2)
> plt.show()
>
> -------------------------------------
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: João L. S. <js...@fc...> - 2010年05月20日 18:11:47
Hi,
I ran into a bug where I get the LaTeX error:
RuntimeError: LaTeX was not able to process the following string: 
''
I know it's an uncommon plot, but I need extra (non-uniform) tick labels 
at the top so I'm using SubplotHost, on a semilog plot with usetex (so 
the fonts look similar to the ones on the paper).
Matplotlib svn r8330 on Ubuntu 9.10.
Regards,
João Silva
Example script: -------------------------------------
from matplotlib import rc
rc('text', usetex=True)
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(1)
ax = SubplotHost(fig, 111)
fig.add_subplot(ax)
x = np.arange(1.0,10.0,0.1)
ax.semilogy(x,x**2)
plt.show()
-------------------------------------
From: Eric F. <ef...@ha...> - 2010年05月20日 17:41:47
On 05/19/2010 11:31 PM, Christer Malmberg wrote:
> Thank you for the help, I never knew what the symlog flag did actually.
>
> However, there is still a slight problem:
>
> =====================================================
> x = array([0,1,2,4,6,9,12,24])
> y = array([1000000, 500000, 100000, 100, 5, 1, 1, 1])
> subplot(111)
> plot(x, y)
> yscale('symlog')
> xscale=('linear')
> ylim(-1,10000000)
> show()
> =====================================================
>
> The plot looks exactly like I want it, the problem is when I change the
> "1"'s to "0"'s in the y-array, then I get a:
>
> File "C:\Python26\lib\site-packages\matplotlib\ticker.py", line 1029, in
> is_decade
> lx = math.log(x)/math.log(base)
> ValueError: math domain error
>
> I suppose that means somewhere a log(0) is attempted. This kind of
> defeats the purpose...
Yes, it looks like a bug that can be fixed fairly easily. In the 
meantime, a workaround is to add the kwarg "scaley=False" to your call 
to "plot"; or more generally, do something like
ax = subplot(111)
ax.set_autoscaley_on(False)
before proceeding with any plotting commands.
Eric
>
> /C
>
> Quoting Eric Firing <ef...@ha...>:
>
>> On 05/19/2010 10:28 AM, Benjamin Root wrote:
>>> Maybe I am misunderstanding your problem, but you can select 'semilog'
>>> for the x/yscale parameter.
>>
>> You mean "symlog".
>>
>> See
>> http://matplotlib.sourceforge.net/examples/pylab_examples/symlog_demo.html
>>
>>
>> Although the example doesn't show it, the axis limits don't have to be
>> symmetric. For example, on the top plot, you can use
>>
>> gca().set_xlim([0, 100])
>>
>> to show only the right-hand side.
>>
>> Eric
>>
>>
>>>
>>> Ben Root
>>>
>>> On Wed, May 19, 2010 at 7:03 AM, Christer Malmberg
>>> <Chr...@st...
>>> <mailto:Chr...@st...>> wrote:
>>>
>>> Hi,
>>>
>>> my problem is that I need a graph with a discontinous y-axis. Let me
>>> explain the problem: in my field (microbiology) the data generated
>>> from for example growth assays have a huge range (10^0-10^9), which
>>> has to be plotted on a semilogy style plot (cell concentration vs.
>>> time). The problem is that 0 cells is a useful number to plot
>>> (indicates cell concentration lower than detection limit), but of
>>> course not possible to show in a log diagram. This is easily solved on
>>> old-style logarithmic graph paper; since the data will be either 0, or
>>> >1 it is customary just to draw a zero x-axis at 10^-1 on the paper
>>> and that's that. On the computer, this is extremely hard. Most people
>>> I know resort to various tricks in Excel, such as entering a small
>>> number (0.001 etc) and starting the y-axis range from 10^1 to hide the
>>> problem. This makes excel draw a line, instead of leaving out the dot
>>> and line entirely. The part of the curve below the x-axis is then
>>> manually cut off in a suitable image editor. Needless to say, this is
>>> extremely kludgy. Even professional graphing packages like Graphpad
>>> Prism resort to similar kludges (re-define 0 values to 0.1, change the
>>> y-axis tick label to "0" etc.) This problem of course exists in other
>>> fields, while investigating a solution I found a guy who worked with
>>> aerosol contamination in clean rooms, and he needed to plot values
>>> logarithmically, at the same time as showing detector noise around
>>> 1-10 particles. He solved it by the same trick I would like to do in
>>> Matplotlib, namely plotting a standard semilogy plot but with the
>>> 10^-1 to 10^0 decade being replaced by a 0-1 linear axis on the same
>>> side.
>>>
>>> The guy in this post has the same problem and a useful example:
>>> http://ubuntuforums.org/showthread.php?t=394851
>>>
>>> His partial solution is quite bad though, and I just got stuck while
>>> trying to improve it. I looked around the gallery for useful examples,
>>> and the closest I could find is the twinx/twiny function, but I didn't
>>> manage a plot that put one data curve across both axes.
>>>
>>> This code gives an image that maybe explains what I'm trying to do:
>>>
>>> =======================================
>>> t = array([0,1,2,4,6,9,12,24])
>>> y = array([1000000, 500000, 100000, 100, 5, 1, 0, 0])
>>> subplot(111, xscale="linear", yscale="log")
>>> errorbar(x, y, yerr=0.4*y)
>>> linbit = axes([0.125, 0.1, 0.775, 0.1],frameon=False)
>>> linbit.xaxis.set_visible(False)
>>> for tl in linbit.get_yticklabels():
>>> tl.set_color('r')
>>> show()
>>> =======================================
>>>
>>> (the y=0 points should be plotted and connected to the line in the
>>> log part)
>>>
>>> Is this possible to do in matplotlib? Could someone give me a pointer
>>> on how to go on?
>>>
>>> Sorry for the long mail,
>>>
>>> /C
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> <mailto:Mat...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>> ------------------------------------------------------------------------------
>>
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
>
From: Michael D. <md...@st...> - 2010年05月20日 17:23:45
On 05/20/2010 11:32 AM, Ryan May wrote:
> On Thu, May 20, 2010 at 9:34 AM, Michael Droettboom<md...@st...> wrote:
> 
>> It is a bug, but the broken behavior was kept for backward
>> compatibility. Try setting the vertical alignment to 'baseline'.
>>
>> import matplotlib.pyplot as plt
>> fig=plt.figure()
>> plt.text(0.4,0.5,"some text", verticalalignment='baseline')
>> plt.text(0.6,0.5,"some text with a g in it", verticalalignment='baseline')
>>
>> It's probably about time to fix this -- we will have to update many of
>> the unit tests -- what do the rest of the devs think?
>> 
> I'm +1, but I've been bitten by this and am not concerned personally
> with the backwards incompatibility. I'm not sure how much code out
> there is dependant on this.
>
> 
I've made baseline the default in SVN r8330. Only two of the unit tests 
changed due to this -- so hopefully it won't be too disruptive for users 
at large.
Mike
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Ryan M. <rm...@gm...> - 2010年05月20日 15:33:22
On Thu, May 20, 2010 at 9:34 AM, Michael Droettboom <md...@st...> wrote:
> It is a bug, but the broken behavior was kept for backward
> compatibility. Try setting the vertical alignment to 'baseline'.
>
> import matplotlib.pyplot as plt
> fig=plt.figure()
> plt.text(0.4,0.5,"some text", verticalalignment='baseline')
> plt.text(0.6,0.5,"some text with a g in it", verticalalignment='baseline')
>
> It's probably about time to fix this -- we will have to update many of
> the unit tests -- what do the rest of the devs think?
I'm +1, but I've been bitten by this and am not concerned personally
with the backwards incompatibility. I'm not sure how much code out
there is dependant on this.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Benjamin R. <ben...@ou...> - 2010年05月20日 14:50:41
Ok, good, I just wanted to do a sanity check.
On Thu, May 20, 2010 at 9:21 AM, Michael Droettboom <md...@st...> wrote:
> In this case, yes. The assumption of these (private) functions is that
> x will be non-negative. The only case where we need to worry about log
> raising an exception is with exactly 0.
>
> Mike
>
> On 05/20/2010 10:08 AM, Benjamin Root wrote:
> > Do we really want to depend on a floating point equality?
> >
> > Ben Root
> >
> > On Thu, May 20, 2010 at 9:02 AM, Michael Droettboom<md...@st...>
> wrote:
> >
> >
> >> Yep. That's a bug. Here's a patch to fix it:
> >>
> >> ndex: lib/matplotlib/ticker.py
> >> ===================================================================
> >> --- lib/matplotlib/ticker.py (revision 8323)
> >> +++ lib/matplotlib/ticker.py (working copy)
> >> @@ -1178,16 +1178,21 @@
> >>
> >> def decade_down(x, base=10):
> >> 'floor x to the nearest lower decade'
> >> -
> >> + if x == 0.0:
> >> + return -base
> >> lx = math.floor(math.log(x)/math.log(base))
> >> return base**lx
> >>
> >> def decade_up(x, base=10):
> >> 'ceil x to the nearest higher decade'
> >> + if x == 0.0:
> >> + return base
> >> lx = math.ceil(math.log(x)/math.log(base))
> >> return base**lx
> >>
> >> def is_decade(x,base=10):
> >> + if x == 0.0:
> >> + return True
> >> lx = math.log(x)/math.log(base)
> >> return lx==int(lx)
> >>
> >> Mike
> >>
> >> On 05/20/2010 09:43 AM, Christer wrote:
> >>
> >>> Thank you for the help, I never knew what the symlog flag did actually.
> >>>
> >>> However, there is still a slight problem:
> >>>
> >>> =====================================================
> >>> x = array([0,1,2,4,6,9,12,24])
> >>> y = array([1000000, 500000, 100000, 100, 5, 1, 1, 1])
> >>> subplot(111)
> >>> plot(x, y)
> >>> yscale('symlog')
> >>> xscale=('linear')
> >>> ylim(-1,10000000)
> >>> show()
> >>> =====================================================
> >>>
> >>> The plot looks exactly like I want it, the problem is when I change
> >>> the "1"'s to "0"'s in the y-array, then I get a:
> >>>
> >>> File "C:\Python26\lib\site-packages\matplotlib\ticker.py", line 1029,
> >>> in is_decade
> >>> lx = math.log(x)/math.log(base)
> >>> ValueError: math domain error
> >>>
> >>> I suppose that means somewhere a log(0) is attempted. This kind of
> >>> defeats the purpose...
> >>>
> >>> /C
> >>>
> >>> Quoting Eric Firing<ef...@ha...>:
> >>>
> >>>
> >>>
> >>>> On 05/19/2010 10:28 AM, Benjamin Root wrote:
> >>>>
> >>>>
> >>>>> Maybe I am misunderstanding your problem, but you can select
> >>>>>
> >>>>>
> >>> 'semilog'
> >>>
> >>>
> >>>>> for the x/yscale parameter.
> >>>>>
> >>>>>
> >>>> You mean "symlog".
> >>>>
> >>>> See
> >>>>
> >>>>
> >>>>
> >>>
> >>
> http://matplotlib.sourceforge.net/examples/pylab_examples/symlog_demo.html
> >>
> >>>
> >>>> Although the example doesn't show it, the axis limits don't have to be
> >>>> symmetric. For example, on the top plot, you can use
> >>>>
> >>>> gca().set_xlim([0, 100])
> >>>>
> >>>> to show only the right-hand side.
> >>>>
> >>>> Eric
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> Ben Root
> >>>>>
> >>>>> On Wed, May 19, 2010 at 7:03 AM, Christer Malmberg
> >>>>> <Chr...@st...
> >>>>> <mailto:Chr...@st...>> wrote:
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> my problem is that I need a graph with a discontinous y-axis.
> Let
> >>>>>
> >>>>>
> >>> me
> >>>
> >>>
> >>>>> explain the problem: in my field (microbiology) the data
> >>>>>
> >>>>>
> >>> generated
> >>>
> >>>
> >>>>> from for example growth assays have a huge range (10^0-10^9),
> >>>>>
> >>>>>
> >>> which
> >>>
> >>>
> >>>>> has to be plotted on a semilogy style plot (cell concentration
> >>>>>
> >>>>>
> >>> vs.
> >>>
> >>>
> >>>>> time). The problem is that 0 cells is a useful number to plot
> >>>>> (indicates cell concentration lower than detection limit), but
> of
> >>>>> course not possible to show in a log diagram. This is easily
> >>>>>
> >>>>>
> >>> solved on
> >>>
> >>>
> >>>>> old-style logarithmic graph paper; since the data will be
> either
> >>>>>
> >>>>>
> >>> 0, or
> >>>
> >>>
> >>>>> >1 it is customary just to draw a zero x-axis at 10^-1 on the
> >>>>>
> >>>>>
> >>> paper
> >>>
> >>>
> >>>>> and that's that. On the computer, this is extremely hard. Most
> >>>>>
> >>>>>
> >>> people
> >>>
> >>>
> >>>>> I know resort to various tricks in Excel, such as entering a
> >>>>>
> >>>>>
> >>> small
> >>>
> >>>
> >>>>> number (0.001 etc) and starting the y-axis range from 10^1 to
> >>>>>
> >>>>>
> >>> hide the
> >>>
> >>>
> >>>>> problem. This makes excel draw a line, instead of leaving out
> the
> >>>>>
> >>>>>
> >>> dot
> >>>
> >>>
> >>>>> and line entirely. The part of the curve below the x-axis is
> then
> >>>>> manually cut off in a suitable image editor. Needless to say,
> >>>>>
> >>>>>
> >>> this is
> >>>
> >>>
> >>>>> extremely kludgy. Even professional graphing packages like
> >>>>>
> >>>>>
> >>> Graphpad
> >>>
> >>>
> >>>>> Prism resort to similar kludges (re-define 0 values to 0.1,
> >>>>>
> >>>>>
> >>> change the
> >>>
> >>>
> >>>>> y-axis tick label to "0" etc.) This problem of course exists in
> >>>>>
> >>>>>
> >>> other
> >>>
> >>>
> >>>>> fields, while investigating a solution I found a guy who worked
> >>>>>
> >>>>>
> >>> with
> >>>
> >>>
> >>>>> aerosol contamination in clean rooms, and he needed to plot
> >>>>>
> >>>>>
> >>> values
> >>>
> >>>
> >>>>> logarithmically, at the same time as showing detector noise
> >>>>>
> >>>>>
> >>> around
> >>>
> >>>
> >>>>> 1-10 particles. He solved it by the same trick I would like to
> do
> >>>>>
> >>>>>
> >>> in
> >>>
> >>>
> >>>>> Matplotlib, namely plotting a standard semilogy plot but with
> the
> >>>>> 10^-1 to 10^0 decade being replaced by a 0-1 linear axis on the
> >>>>>
> >>>>>
> >>> same
> >>>
> >>>
> >>>>> side.
> >>>>>
> >>>>> The guy in this post has the same problem and a useful example:
> >>>>> http://ubuntuforums.org/showthread.php?t=394851
> >>>>>
> >>>>> His partial solution is quite bad though, and I just got stuck
> >>>>>
> >>>>>
> >>> while
> >>>
> >>>
> >>>>> trying to improve it. I looked around the gallery for useful
> >>>>>
> >>>>>
> >>> examples,
> >>>
> >>>
> >>>>> and the closest I could find is the twinx/twiny function, but I
> >>>>>
> >>>>>
> >>> didn't
> >>>
> >>>
> >>>>> manage a plot that put one data curve across both axes.
> >>>>>
> >>>>> This code gives an image that maybe explains what I'm trying to
> >>>>>
> >>>>>
> >>> do:
> >>>
> >>>
> >>>>> =======================================
> >>>>> t = array([0,1,2,4,6,9,12,24])
> >>>>> y = array([1000000, 500000, 100000, 100, 5, 1, 0, 0])
> >>>>> subplot(111, xscale="linear", yscale="log")
> >>>>> errorbar(x, y, yerr=0.4*y)
> >>>>> linbit = axes([0.125, 0.1, 0.775, 0.1],frameon=False)
> >>>>> linbit.xaxis.set_visible(False)
> >>>>> for tl in linbit.get_yticklabels():
> >>>>> tl.set_color('r')
> >>>>> show()
> >>>>> =======================================
> >>>>>
> >>>>> (the y=0 points should be plotted and connected to the line in
> >>>>>
> >>>>>
> >>> the
> >>>
> >>>
> >>>>> log part)
> >>>>>
> >>>>> Is this possible to do in matplotlib? Could someone give me a
> >>>>>
> >>>>>
> >>> pointer
> >>>
> >>>
> >>>>> on how to go on?
> >>>>>
> >>>>> Sorry for the long mail,
> >>>>>
> >>>>> /C
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>
> ------------------------------------------------------------------------------
> >>
> >>>
> >>>>> _______________________________________________
> >>>>> Matplotlib-users mailing list
> >>>>> Mat...@li...
> >>>>> <mailto:Mat...@li...>
> >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>
> ------------------------------------------------------------------------------
> >>
> >>>
> >>>>>
> >>>>>
> >>>>> _______________________________________________
> >>>>> Matplotlib-users mailing list
> >>>>> Mat...@li...
> >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>
> ------------------------------------------------------------------------------
> >>
> >>>
> >>>> _______________________________________________
> >>>> Matplotlib-users mailing list
> >>>> Mat...@li...
> >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>
> ------------------------------------------------------------------------------
> >>
> >>> _______________________________________________
> >>> Matplotlib-users mailing list
> >>> Mat...@li...
> >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>>
> >>>
> >>
> >> --
> >> Michael Droettboom
> >> Science Software Branch
> >> Space Telescope Science Institute
> >> Baltimore, Maryland, USA
> >>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> Matplotlib-users mailing list
> >> Mat...@li...
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>
> >>
> >
>
>
> --
> Michael Droettboom
> Science Software Branch
> Space Telescope Science Institute
> Baltimore, Maryland, USA
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Michael D. <md...@st...> - 2010年05月20日 14:35:07
It is a bug, but the broken behavior was kept for backward 
compatibility. Try setting the vertical alignment to 'baseline'.
import matplotlib.pyplot as plt
fig=plt.figure()
plt.text(0.4,0.5,"some text", verticalalignment='baseline')
plt.text(0.6,0.5,"some text with a g in it", verticalalignment='baseline')
It's probably about time to fix this -- we will have to update many of 
the unit tests -- what do the rest of the devs think?
Mike
On 05/20/2010 10:28 AM, Nick Schurch wrote:
> I've also discovered another text problem. If I add two lines of test
> to a plot as follows:
>
> import mapplotlib.pyplot as plt
> fig=plt.figure()
> plt.text(0.4,0.5,"some text")
> plt.text(0.6,0.5,"some more text")
>
> then the two sets of text line up nicely with each other, because they
> have the same y-axis position. But if I do:
>
> import mapplotlib.pyplot as plt
> fig=plt.figure()
> plt.text(0.4,0.5,"some text")
> plt.text(0.6,0.5,"some text with a g in it")
>
> then the "some text with a g in it" is shifted upwards slightly so
> that the bottom of "some text" lines up with the bottom of the "g",
> and doesn't line up witht he rest of the letters. It look like they
> are not on the same line! This has got to be a bug in the way
> matplotlib deals with text.
>
> --
> Cheers,
>
> Nick Schurch
>
> Data Analysis Group (The Barton Group),
> School of Life Sciences,
> University of Dundee,
> Dow St,
> Dundee,
> DD1 5EH,
> Scotland,
> UK
>
> Tel: +44 1382 388707
> Fax: +44 1382 345 893
>
>
>
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Michael D. <md...@st...> - 2010年05月20日 14:32:18
That will only work if you have a small-caps variant of the font 
installed (which the vast majority of fonts do not). matplotlib does 
not do any font synthesis at all -- i.e. it does not create a pseudo 
font variation when one does not exist on disk.
Mike
On 05/20/2010 10:19 AM, Nick Schurch wrote:
> Hi all,
>
> I'm adding some text to a plt like this:
>
> import mapplotlib.pyplot as plt
> fig=plt.figure()
> plt.text(0.5,0.5,"some text", variant='small-caps')
>
> but the text that is plotted is not small caps, its just normal. Is
> this a bug or am I doing something wrong?
>
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Nick S. <N.S...@du...> - 2010年05月20日 14:29:15
I've also discovered another text problem. If I add two lines of test
to a plot as follows:
import mapplotlib.pyplot as plt
fig=plt.figure()
plt.text(0.4,0.5,"some text")
plt.text(0.6,0.5,"some more text")
then the two sets of text line up nicely with each other, because they
have the same y-axis position. But if I do:
import mapplotlib.pyplot as plt
fig=plt.figure()
plt.text(0.4,0.5,"some text")
plt.text(0.6,0.5,"some text with a g in it")
then the "some text with a g in it" is shifted upwards slightly so
that the bottom of "some text" lines up with the bottom of the "g",
and doesn't line up witht he rest of the letters. It look like they
are not on the same line! This has got to be a bug in the way
matplotlib deals with text.
--
Cheers,
Nick Schurch
Data Analysis Group (The Barton Group),
School of Life Sciences,
University of Dundee,
Dow St,
Dundee,
DD1 5EH,
Scotland,
UK
Tel: +44 1382 388707
Fax: +44 1382 345 893
-- 
Cheers,
Nick Schurch
Data Analysis Group (The Barton Group),
School of Life Sciences,
University of Dundee,
Dow St,
Dundee,
DD1 5EH,
Scotland,
UK
Tel: +44 1382 388707
Fax: +44 1382 345 893
From: Michael D. <md...@st...> - 2010年05月20日 14:22:52
In this case, yes. The assumption of these (private) functions is that 
x will be non-negative. The only case where we need to worry about log 
raising an exception is with exactly 0.
Mike
On 05/20/2010 10:08 AM, Benjamin Root wrote:
> Do we really want to depend on a floating point equality?
>
> Ben Root
>
> On Thu, May 20, 2010 at 9:02 AM, Michael Droettboom<md...@st...> wrote:
>
> 
>> Yep. That's a bug. Here's a patch to fix it:
>>
>> ndex: lib/matplotlib/ticker.py
>> ===================================================================
>> --- lib/matplotlib/ticker.py (revision 8323)
>> +++ lib/matplotlib/ticker.py (working copy)
>> @@ -1178,16 +1178,21 @@
>>
>> def decade_down(x, base=10):
>> 'floor x to the nearest lower decade'
>> -
>> + if x == 0.0:
>> + return -base
>> lx = math.floor(math.log(x)/math.log(base))
>> return base**lx
>>
>> def decade_up(x, base=10):
>> 'ceil x to the nearest higher decade'
>> + if x == 0.0:
>> + return base
>> lx = math.ceil(math.log(x)/math.log(base))
>> return base**lx
>>
>> def is_decade(x,base=10):
>> + if x == 0.0:
>> + return True
>> lx = math.log(x)/math.log(base)
>> return lx==int(lx)
>>
>> Mike
>>
>> On 05/20/2010 09:43 AM, Christer wrote:
>> 
>>> Thank you for the help, I never knew what the symlog flag did actually.
>>>
>>> However, there is still a slight problem:
>>>
>>> =====================================================
>>> x = array([0,1,2,4,6,9,12,24])
>>> y = array([1000000, 500000, 100000, 100, 5, 1, 1, 1])
>>> subplot(111)
>>> plot(x, y)
>>> yscale('symlog')
>>> xscale=('linear')
>>> ylim(-1,10000000)
>>> show()
>>> =====================================================
>>>
>>> The plot looks exactly like I want it, the problem is when I change
>>> the "1"'s to "0"'s in the y-array, then I get a:
>>>
>>> File "C:\Python26\lib\site-packages\matplotlib\ticker.py", line 1029,
>>> in is_decade
>>> lx = math.log(x)/math.log(base)
>>> ValueError: math domain error
>>>
>>> I suppose that means somewhere a log(0) is attempted. This kind of
>>> defeats the purpose...
>>>
>>> /C
>>>
>>> Quoting Eric Firing<ef...@ha...>:
>>>
>>>
>>> 
>>>> On 05/19/2010 10:28 AM, Benjamin Root wrote:
>>>>
>>>> 
>>>>> Maybe I am misunderstanding your problem, but you can select
>>>>>
>>>>> 
>>> 'semilog'
>>>
>>> 
>>>>> for the x/yscale parameter.
>>>>>
>>>>> 
>>>> You mean "symlog".
>>>>
>>>> See
>>>>
>>>>
>>>> 
>>> 
>> http://matplotlib.sourceforge.net/examples/pylab_examples/symlog_demo.html
>> 
>>> 
>>>> Although the example doesn't show it, the axis limits don't have to be
>>>> symmetric. For example, on the top plot, you can use
>>>>
>>>> gca().set_xlim([0, 100])
>>>>
>>>> to show only the right-hand side.
>>>>
>>>> Eric
>>>>
>>>>
>>>>
>>>> 
>>>>> Ben Root
>>>>>
>>>>> On Wed, May 19, 2010 at 7:03 AM, Christer Malmberg
>>>>> <Chr...@st...
>>>>> <mailto:Chr...@st...>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> my problem is that I need a graph with a discontinous y-axis. Let
>>>>>
>>>>> 
>>> me
>>>
>>> 
>>>>> explain the problem: in my field (microbiology) the data
>>>>>
>>>>> 
>>> generated
>>>
>>> 
>>>>> from for example growth assays have a huge range (10^0-10^9),
>>>>>
>>>>> 
>>> which
>>>
>>> 
>>>>> has to be plotted on a semilogy style plot (cell concentration
>>>>>
>>>>> 
>>> vs.
>>>
>>> 
>>>>> time). The problem is that 0 cells is a useful number to plot
>>>>> (indicates cell concentration lower than detection limit), but of
>>>>> course not possible to show in a log diagram. This is easily
>>>>>
>>>>> 
>>> solved on
>>>
>>> 
>>>>> old-style logarithmic graph paper; since the data will be either
>>>>>
>>>>> 
>>> 0, or
>>>
>>> 
>>>>> >1 it is customary just to draw a zero x-axis at 10^-1 on the
>>>>>
>>>>> 
>>> paper
>>>
>>> 
>>>>> and that's that. On the computer, this is extremely hard. Most
>>>>>
>>>>> 
>>> people
>>>
>>> 
>>>>> I know resort to various tricks in Excel, such as entering a
>>>>>
>>>>> 
>>> small
>>>
>>> 
>>>>> number (0.001 etc) and starting the y-axis range from 10^1 to
>>>>>
>>>>> 
>>> hide the
>>>
>>> 
>>>>> problem. This makes excel draw a line, instead of leaving out the
>>>>>
>>>>> 
>>> dot
>>>
>>> 
>>>>> and line entirely. The part of the curve below the x-axis is then
>>>>> manually cut off in a suitable image editor. Needless to say,
>>>>>
>>>>> 
>>> this is
>>>
>>> 
>>>>> extremely kludgy. Even professional graphing packages like
>>>>>
>>>>> 
>>> Graphpad
>>>
>>> 
>>>>> Prism resort to similar kludges (re-define 0 values to 0.1,
>>>>>
>>>>> 
>>> change the
>>>
>>> 
>>>>> y-axis tick label to "0" etc.) This problem of course exists in
>>>>>
>>>>> 
>>> other
>>>
>>> 
>>>>> fields, while investigating a solution I found a guy who worked
>>>>>
>>>>> 
>>> with
>>>
>>> 
>>>>> aerosol contamination in clean rooms, and he needed to plot
>>>>>
>>>>> 
>>> values
>>>
>>> 
>>>>> logarithmically, at the same time as showing detector noise
>>>>>
>>>>> 
>>> around
>>>
>>> 
>>>>> 1-10 particles. He solved it by the same trick I would like to do
>>>>>
>>>>> 
>>> in
>>>
>>> 
>>>>> Matplotlib, namely plotting a standard semilogy plot but with the
>>>>> 10^-1 to 10^0 decade being replaced by a 0-1 linear axis on the
>>>>>
>>>>> 
>>> same
>>>
>>> 
>>>>> side.
>>>>>
>>>>> The guy in this post has the same problem and a useful example:
>>>>> http://ubuntuforums.org/showthread.php?t=394851
>>>>>
>>>>> His partial solution is quite bad though, and I just got stuck
>>>>>
>>>>> 
>>> while
>>>
>>> 
>>>>> trying to improve it. I looked around the gallery for useful
>>>>>
>>>>> 
>>> examples,
>>>
>>> 
>>>>> and the closest I could find is the twinx/twiny function, but I
>>>>>
>>>>> 
>>> didn't
>>>
>>> 
>>>>> manage a plot that put one data curve across both axes.
>>>>>
>>>>> This code gives an image that maybe explains what I'm trying to
>>>>>
>>>>> 
>>> do:
>>>
>>> 
>>>>> =======================================
>>>>> t = array([0,1,2,4,6,9,12,24])
>>>>> y = array([1000000, 500000, 100000, 100, 5, 1, 0, 0])
>>>>> subplot(111, xscale="linear", yscale="log")
>>>>> errorbar(x, y, yerr=0.4*y)
>>>>> linbit = axes([0.125, 0.1, 0.775, 0.1],frameon=False)
>>>>> linbit.xaxis.set_visible(False)
>>>>> for tl in linbit.get_yticklabels():
>>>>> tl.set_color('r')
>>>>> show()
>>>>> =======================================
>>>>>
>>>>> (the y=0 points should be plotted and connected to the line in
>>>>>
>>>>> 
>>> the
>>>
>>> 
>>>>> log part)
>>>>>
>>>>> Is this possible to do in matplotlib? Could someone give me a
>>>>>
>>>>> 
>>> pointer
>>>
>>> 
>>>>> on how to go on?
>>>>>
>>>>> Sorry for the long mail,
>>>>>
>>>>> /C
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 
>>> 
>> ------------------------------------------------------------------------------
>> 
>>> 
>>>>> _______________________________________________
>>>>> Matplotlib-users mailing list
>>>>> Mat...@li...
>>>>> <mailto:Mat...@li...>
>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 
>>> 
>> ------------------------------------------------------------------------------
>> 
>>> 
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Matplotlib-users mailing list
>>>>> Mat...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>>
>>>>> 
>>>>
>>>>
>>>> 
>>> 
>> ------------------------------------------------------------------------------
>> 
>>> 
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> Mat...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>
>>>>
>>>> 
>>>
>>>
>>> 
>> ------------------------------------------------------------------------------
>> 
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>> 
>>
>> --
>> Michael Droettboom
>> Science Software Branch
>> Space Telescope Science Institute
>> Baltimore, Maryland, USA
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> 
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Nick S. <N.S...@du...> - 2010年05月20日 14:20:08
Hi all,
I'm adding some text to a plt like this:
import mapplotlib.pyplot as plt
fig=plt.figure()
plt.text(0.5,0.5,"some text", variant='small-caps')
but the text that is plotted is not small caps, its just normal. Is
this a bug or am I doing something wrong?
-- 
Cheers,
Nick Schurch
Data Analysis Group (The Barton Group),
School of Life Sciences,
University of Dundee,
Dow St,
Dundee,
DD1 5EH,
Scotland,
UK
Tel: +44 1382 388707
Fax: +44 1382 345 893
From: Benjamin R. <ben...@ou...> - 2010年05月20日 14:09:24
Do we really want to depend on a floating point equality?
Ben Root
On Thu, May 20, 2010 at 9:02 AM, Michael Droettboom <md...@st...> wrote:
> Yep. That's a bug. Here's a patch to fix it:
>
> ndex: lib/matplotlib/ticker.py
> ===================================================================
> --- lib/matplotlib/ticker.py (revision 8323)
> +++ lib/matplotlib/ticker.py (working copy)
> @@ -1178,16 +1178,21 @@
>
> def decade_down(x, base=10):
> 'floor x to the nearest lower decade'
> -
> + if x == 0.0:
> + return -base
> lx = math.floor(math.log(x)/math.log(base))
> return base**lx
>
> def decade_up(x, base=10):
> 'ceil x to the nearest higher decade'
> + if x == 0.0:
> + return base
> lx = math.ceil(math.log(x)/math.log(base))
> return base**lx
>
> def is_decade(x,base=10):
> + if x == 0.0:
> + return True
> lx = math.log(x)/math.log(base)
> return lx==int(lx)
>
> Mike
>
> On 05/20/2010 09:43 AM, Christer wrote:
> > Thank you for the help, I never knew what the symlog flag did actually.
> >
> > However, there is still a slight problem:
> >
> > =====================================================
> > x = array([0,1,2,4,6,9,12,24])
> > y = array([1000000, 500000, 100000, 100, 5, 1, 1, 1])
> > subplot(111)
> > plot(x, y)
> > yscale('symlog')
> > xscale=('linear')
> > ylim(-1,10000000)
> > show()
> > =====================================================
> >
> > The plot looks exactly like I want it, the problem is when I change
> > the "1"'s to "0"'s in the y-array, then I get a:
> >
> > File "C:\Python26\lib\site-packages\matplotlib\ticker.py", line 1029,
> > in is_decade
> > lx = math.log(x)/math.log(base)
> > ValueError: math domain error
> >
> > I suppose that means somewhere a log(0) is attempted. This kind of
> > defeats the purpose...
> >
> > /C
> >
> > Quoting Eric Firing<ef...@ha...>:
> >
> >
> >> On 05/19/2010 10:28 AM, Benjamin Root wrote:
> >>
> >>> Maybe I am misunderstanding your problem, but you can select
> >>>
> > 'semilog'
> >
> >>> for the x/yscale parameter.
> >>>
> >> You mean "symlog".
> >>
> >> See
> >>
> >>
> >
> http://matplotlib.sourceforge.net/examples/pylab_examples/symlog_demo.html
> >
> >> Although the example doesn't show it, the axis limits don't have to be
> >> symmetric. For example, on the top plot, you can use
> >>
> >> gca().set_xlim([0, 100])
> >>
> >> to show only the right-hand side.
> >>
> >> Eric
> >>
> >>
> >>
> >>> Ben Root
> >>>
> >>> On Wed, May 19, 2010 at 7:03 AM, Christer Malmberg
> >>> <Chr...@st...
> >>> <mailto:Chr...@st...>> wrote:
> >>>
> >>> Hi,
> >>>
> >>> my problem is that I need a graph with a discontinous y-axis. Let
> >>>
> > me
> >
> >>> explain the problem: in my field (microbiology) the data
> >>>
> > generated
> >
> >>> from for example growth assays have a huge range (10^0-10^9),
> >>>
> > which
> >
> >>> has to be plotted on a semilogy style plot (cell concentration
> >>>
> > vs.
> >
> >>> time). The problem is that 0 cells is a useful number to plot
> >>> (indicates cell concentration lower than detection limit), but of
> >>> course not possible to show in a log diagram. This is easily
> >>>
> > solved on
> >
> >>> old-style logarithmic graph paper; since the data will be either
> >>>
> > 0, or
> >
> >>> >1 it is customary just to draw a zero x-axis at 10^-1 on the
> >>>
> > paper
> >
> >>> and that's that. On the computer, this is extremely hard. Most
> >>>
> > people
> >
> >>> I know resort to various tricks in Excel, such as entering a
> >>>
> > small
> >
> >>> number (0.001 etc) and starting the y-axis range from 10^1 to
> >>>
> > hide the
> >
> >>> problem. This makes excel draw a line, instead of leaving out the
> >>>
> > dot
> >
> >>> and line entirely. The part of the curve below the x-axis is then
> >>> manually cut off in a suitable image editor. Needless to say,
> >>>
> > this is
> >
> >>> extremely kludgy. Even professional graphing packages like
> >>>
> > Graphpad
> >
> >>> Prism resort to similar kludges (re-define 0 values to 0.1,
> >>>
> > change the
> >
> >>> y-axis tick label to "0" etc.) This problem of course exists in
> >>>
> > other
> >
> >>> fields, while investigating a solution I found a guy who worked
> >>>
> > with
> >
> >>> aerosol contamination in clean rooms, and he needed to plot
> >>>
> > values
> >
> >>> logarithmically, at the same time as showing detector noise
> >>>
> > around
> >
> >>> 1-10 particles. He solved it by the same trick I would like to do
> >>>
> > in
> >
> >>> Matplotlib, namely plotting a standard semilogy plot but with the
> >>> 10^-1 to 10^0 decade being replaced by a 0-1 linear axis on the
> >>>
> > same
> >
> >>> side.
> >>>
> >>> The guy in this post has the same problem and a useful example:
> >>> http://ubuntuforums.org/showthread.php?t=394851
> >>>
> >>> His partial solution is quite bad though, and I just got stuck
> >>>
> > while
> >
> >>> trying to improve it. I looked around the gallery for useful
> >>>
> > examples,
> >
> >>> and the closest I could find is the twinx/twiny function, but I
> >>>
> > didn't
> >
> >>> manage a plot that put one data curve across both axes.
> >>>
> >>> This code gives an image that maybe explains what I'm trying to
> >>>
> > do:
> >
> >>> =======================================
> >>> t = array([0,1,2,4,6,9,12,24])
> >>> y = array([1000000, 500000, 100000, 100, 5, 1, 0, 0])
> >>> subplot(111, xscale="linear", yscale="log")
> >>> errorbar(x, y, yerr=0.4*y)
> >>> linbit = axes([0.125, 0.1, 0.775, 0.1],frameon=False)
> >>> linbit.xaxis.set_visible(False)
> >>> for tl in linbit.get_yticklabels():
> >>> tl.set_color('r')
> >>> show()
> >>> =======================================
> >>>
> >>> (the y=0 points should be plotted and connected to the line in
> >>>
> > the
> >
> >>> log part)
> >>>
> >>> Is this possible to do in matplotlib? Could someone give me a
> >>>
> > pointer
> >
> >>> on how to go on?
> >>>
> >>> Sorry for the long mail,
> >>>
> >>> /C
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> ------------------------------------------------------------------------------
> >
> >>> _______________________________________________
> >>> Matplotlib-users mailing list
> >>> Mat...@li...
> >>> <mailto:Mat...@li...>
> >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> ------------------------------------------------------------------------------
> >
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Matplotlib-users mailing list
> >>> Mat...@li...
> >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>>
> >>
> >>
> >>
> >
> ------------------------------------------------------------------------------
> >
> >> _______________________________________________
> >> Matplotlib-users mailing list
> >> Mat...@li...
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>
> >>
> >
> >
> >
> ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
>
> --
> Michael Droettboom
> Science Software Branch
> Space Telescope Science Institute
> Baltimore, Maryland, USA
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Michael D. <md...@st...> - 2010年05月20日 14:02:51
Yep. That's a bug. Here's a patch to fix it:
ndex: lib/matplotlib/ticker.py
===================================================================
--- lib/matplotlib/ticker.py (revision 8323)
+++ lib/matplotlib/ticker.py (working copy)
@@ -1178,16 +1178,21 @@
 def decade_down(x, base=10):
 'floor x to the nearest lower decade'
-
+ if x == 0.0:
+ return -base
 lx = math.floor(math.log(x)/math.log(base))
 return base**lx
 def decade_up(x, base=10):
 'ceil x to the nearest higher decade'
+ if x == 0.0:
+ return base
 lx = math.ceil(math.log(x)/math.log(base))
 return base**lx
 def is_decade(x,base=10):
+ if x == 0.0:
+ return True
 lx = math.log(x)/math.log(base)
 return lx==int(lx)
Mike
On 05/20/2010 09:43 AM, Christer wrote:
> Thank you for the help, I never knew what the symlog flag did actually.
>
> However, there is still a slight problem:
>
> =====================================================
> x = array([0,1,2,4,6,9,12,24])
> y = array([1000000, 500000, 100000, 100, 5, 1, 1, 1])
> subplot(111)
> plot(x, y)
> yscale('symlog')
> xscale=('linear')
> ylim(-1,10000000)
> show()
> =====================================================
>
> The plot looks exactly like I want it, the problem is when I change
> the "1"'s to "0"'s in the y-array, then I get a:
>
> File "C:\Python26\lib\site-packages\matplotlib\ticker.py", line 1029,
> in is_decade
> lx = math.log(x)/math.log(base)
> ValueError: math domain error
>
> I suppose that means somewhere a log(0) is attempted. This kind of
> defeats the purpose...
>
> /C
>
> Quoting Eric Firing<ef...@ha...>:
>
> 
>> On 05/19/2010 10:28 AM, Benjamin Root wrote:
>> 
>>> Maybe I am misunderstanding your problem, but you can select
>>> 
> 'semilog'
> 
>>> for the x/yscale parameter.
>>> 
>> You mean "symlog".
>>
>> See
>>
>> 
> http://matplotlib.sourceforge.net/examples/pylab_examples/symlog_demo.html
> 
>> Although the example doesn't show it, the axis limits don't have to be
>> symmetric. For example, on the top plot, you can use
>>
>> gca().set_xlim([0, 100])
>>
>> to show only the right-hand side.
>>
>> Eric
>>
>>
>> 
>>> Ben Root
>>>
>>> On Wed, May 19, 2010 at 7:03 AM, Christer Malmberg
>>> <Chr...@st...
>>> <mailto:Chr...@st...>> wrote:
>>>
>>> Hi,
>>>
>>> my problem is that I need a graph with a discontinous y-axis. Let
>>> 
> me
> 
>>> explain the problem: in my field (microbiology) the data
>>> 
> generated
> 
>>> from for example growth assays have a huge range (10^0-10^9),
>>> 
> which
> 
>>> has to be plotted on a semilogy style plot (cell concentration
>>> 
> vs.
> 
>>> time). The problem is that 0 cells is a useful number to plot
>>> (indicates cell concentration lower than detection limit), but of
>>> course not possible to show in a log diagram. This is easily
>>> 
> solved on
> 
>>> old-style logarithmic graph paper; since the data will be either
>>> 
> 0, or
> 
>>> >1 it is customary just to draw a zero x-axis at 10^-1 on the
>>> 
> paper
> 
>>> and that's that. On the computer, this is extremely hard. Most
>>> 
> people
> 
>>> I know resort to various tricks in Excel, such as entering a
>>> 
> small
> 
>>> number (0.001 etc) and starting the y-axis range from 10^1 to
>>> 
> hide the
> 
>>> problem. This makes excel draw a line, instead of leaving out the
>>> 
> dot
> 
>>> and line entirely. The part of the curve below the x-axis is then
>>> manually cut off in a suitable image editor. Needless to say,
>>> 
> this is
> 
>>> extremely kludgy. Even professional graphing packages like
>>> 
> Graphpad
> 
>>> Prism resort to similar kludges (re-define 0 values to 0.1,
>>> 
> change the
> 
>>> y-axis tick label to "0" etc.) This problem of course exists in
>>> 
> other
> 
>>> fields, while investigating a solution I found a guy who worked
>>> 
> with
> 
>>> aerosol contamination in clean rooms, and he needed to plot
>>> 
> values
> 
>>> logarithmically, at the same time as showing detector noise
>>> 
> around
> 
>>> 1-10 particles. He solved it by the same trick I would like to do
>>> 
> in
> 
>>> Matplotlib, namely plotting a standard semilogy plot but with the
>>> 10^-1 to 10^0 decade being replaced by a 0-1 linear axis on the
>>> 
> same
> 
>>> side.
>>>
>>> The guy in this post has the same problem and a useful example:
>>> http://ubuntuforums.org/showthread.php?t=394851
>>>
>>> His partial solution is quite bad though, and I just got stuck
>>> 
> while
> 
>>> trying to improve it. I looked around the gallery for useful
>>> 
> examples,
> 
>>> and the closest I could find is the twinx/twiny function, but I
>>> 
> didn't
> 
>>> manage a plot that put one data curve across both axes.
>>>
>>> This code gives an image that maybe explains what I'm trying to
>>> 
> do:
> 
>>> =======================================
>>> t = array([0,1,2,4,6,9,12,24])
>>> y = array([1000000, 500000, 100000, 100, 5, 1, 0, 0])
>>> subplot(111, xscale="linear", yscale="log")
>>> errorbar(x, y, yerr=0.4*y)
>>> linbit = axes([0.125, 0.1, 0.775, 0.1],frameon=False)
>>> linbit.xaxis.set_visible(False)
>>> for tl in linbit.get_yticklabels():
>>> tl.set_color('r')
>>> show()
>>> =======================================
>>>
>>> (the y=0 points should be plotted and connected to the line in
>>> 
> the
> 
>>> log part)
>>>
>>> Is this possible to do in matplotlib? Could someone give me a
>>> 
> pointer
> 
>>> on how to go on?
>>>
>>> Sorry for the long mail,
>>>
>>> /C
>>>
>>>
>>>
>>>
>>> 
> ------------------------------------------------------------------------------
> 
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> <mailto:Mat...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>>
>>>
>>>
>>> 
> ------------------------------------------------------------------------------
> 
>>>
>>>
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>>
>>
>> 
> ------------------------------------------------------------------------------
> 
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> 
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Christer <chm...@st...> - 2010年05月20日 13:43:54
Thank you for the help, I never knew what the symlog flag did actually.
However, there is still a slight problem:
=====================================================
x = array([0,1,2,4,6,9,12,24])
y = array([1000000, 500000, 100000, 100, 5, 1, 1, 1])
subplot(111)
plot(x, y)
yscale('symlog')
xscale=('linear')
ylim(-1,10000000)
show()
=====================================================
The plot looks exactly like I want it, the problem is when I change 
the "1"'s to "0"'s in the y-array, then I get a:
File "C:\Python26\lib\site-packages\matplotlib\ticker.py", line 1029, 
in is_decade
 lx = math.log(x)/math.log(base)
ValueError: math domain error
I suppose that means somewhere a log(0) is attempted. This kind of 
defeats the purpose...
/C
Quoting Eric Firing <ef...@ha...>:
> On 05/19/2010 10:28 AM, Benjamin Root wrote:
>> Maybe I am misunderstanding your problem, but you can select
'semilog'
>> for the x/yscale parameter.
>
> You mean "symlog".
>
> See
>
http://matplotlib.sourceforge.net/examples/pylab_examples/symlog_demo.html
>
> Although the example doesn't show it, the axis limits don't have to be
> symmetric. For example, on the top plot, you can use
>
> gca().set_xlim([0, 100])
>
> to show only the right-hand side.
>
> Eric
>
>
>>
>> Ben Root
>>
>> On Wed, May 19, 2010 at 7:03 AM, Christer Malmberg
>> <Chr...@st...
>> <mailto:Chr...@st...>> wrote:
>>
>> Hi,
>>
>> my problem is that I need a graph with a discontinous y-axis. Let
me
>> explain the problem: in my field (microbiology) the data
generated
>> from for example growth assays have a huge range (10^0-10^9),
which
>> has to be plotted on a semilogy style plot (cell concentration
vs.
>> time). The problem is that 0 cells is a useful number to plot
>> (indicates cell concentration lower than detection limit), but of
>> course not possible to show in a log diagram. This is easily
solved on
>> old-style logarithmic graph paper; since the data will be either
0, or
>> >1 it is customary just to draw a zero x-axis at 10^-1 on the
paper
>> and that's that. On the computer, this is extremely hard. Most
people
>> I know resort to various tricks in Excel, such as entering a
small
>> number (0.001 etc) and starting the y-axis range from 10^1 to
hide the
>> problem. This makes excel draw a line, instead of leaving out the
dot
>> and line entirely. The part of the curve below the x-axis is then
>> manually cut off in a suitable image editor. Needless to say,
this is
>> extremely kludgy. Even professional graphing packages like
Graphpad
>> Prism resort to similar kludges (re-define 0 values to 0.1,
change the
>> y-axis tick label to "0" etc.) This problem of course exists in
other
>> fields, while investigating a solution I found a guy who worked
with
>> aerosol contamination in clean rooms, and he needed to plot
values
>> logarithmically, at the same time as showing detector noise
around
>> 1-10 particles. He solved it by the same trick I would like to do
in
>> Matplotlib, namely plotting a standard semilogy plot but with the
>> 10^-1 to 10^0 decade being replaced by a 0-1 linear axis on the
same
>> side.
>>
>> The guy in this post has the same problem and a useful example:
>> http://ubuntuforums.org/showthread.php?t=394851
>>
>> His partial solution is quite bad though, and I just got stuck
while
>> trying to improve it. I looked around the gallery for useful
examples,
>> and the closest I could find is the twinx/twiny function, but I
didn't
>> manage a plot that put one data curve across both axes.
>>
>> This code gives an image that maybe explains what I'm trying to
do:
>>
>> =======================================
>> t = array([0,1,2,4,6,9,12,24])
>> y = array([1000000, 500000, 100000, 100, 5, 1, 0, 0])
>> subplot(111, xscale="linear", yscale="log")
>> errorbar(x, y, yerr=0.4*y)
>> linbit = axes([0.125, 0.1, 0.775, 0.1],frameon=False)
>> linbit.xaxis.set_visible(False)
>> for tl in linbit.get_yticklabels():
>> tl.set_color('r')
>> show()
>> =======================================
>>
>> (the y=0 points should be plotted and connected to the line in
the
>> log part)
>>
>> Is this possible to do in matplotlib? Could someone give me a
pointer
>> on how to go on?
>>
>> Sorry for the long mail,
>>
>> /C
>>
>>
>> 
>>
------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> <mailto:Mat...@li...>
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>>
>>
------------------------------------------------------------------------------
>>
>>
>>
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Alan G I. <ala...@gm...> - 2010年05月20日 12:26:38
On 5/18/2010 9:53 AM, Nick Schurch wrote:
> Is there anyway of re-ploting the distribution generated by hist at a
> later point?
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html
hth,
Alan Isaac

Showing results of 27

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