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






Showing 5 results of 5

From: matthew a. <ma...@ca...> - 2004年02月04日 05:26:39
On Tue, 3 Feb 2004, John Hunter wrote:
> So enough excuses! I agree that the current implementation is
> suboptimal and will give it some more thought. Out of curiosity: do
> the undersirable tick locs appear more frequently for you on an
> initial plot or after interacting with the plot.
I haven't been using the pan and zoom stuff very much, the issues I 
described this week are all from initial plots. If I had been doing more 
zooming then I would have noticed your very good point about jumping 
ticks being distracting. It's fiddly stuff, but getting it right helps a 
lot when interpreting results from plots!
> This is a consequence of the way python and Numeric do ranges, and
> doesn't really have anything to do with matplotlib. eg, the Numeric
> function arange
> 
> >>> from Numeric import *
> >>> arange(0.0, 1.0, 0.2)
> array([ 0. , 0.2, 0.4, 0.6, 0.8])
> 
> >>> range(5)
> [0, 1, 2, 3, 4]
> 
> Ie, ignore the end point is the default behavior of python.
I guessed as much. But I think in this case the python behaviour needs to 
be over-ridden. Python range logic is generally about integers, arange 
stretches it, and using this [) style range for plots over-stretches the 
principle beyond usefulness. There are also a couple of contradictions in 
matplotlib's behaviour:
* the axis and tick ranges are inclusive, but the data point range is 
exclusive of the higher end point only
* the auto data range (axis()) is inclusive, but setting it manually is 
exclusive of the higher end point only
Some of this may be alleviated by chooing better tick points. But I think 
it would also be helpful to make whichever behaviour is chosen more 
consistent.
Cheers,
Matthew.
From: John H. <jdh...@ac...> - 2004年02月04日 03:17:23
>>>>> "Jean-Baptiste" =3D=3D Jean-Baptiste Cazier <Jean-Baptiste.cazier@d=
ecode.is> writes:
 Jean-Baptiste> S=E6ll ! I am trying to plot very small number for
 Jean-Baptiste> the Y-axis on semilogy but they do not appear at
 Jean-Baptiste> all unless one of the value is higher Moreover the
 Jean-Baptiste> labels on the Y axis become 0 below 0.001
 >>> semilogy([1.0, 2.3, 3.3],[9.4e-05, 9.4e-05, 9.4e-05]) <-- does
 >>> not work
 Jean-Baptiste> [<matplotlib.lines.Line2D instance at 0x935255c>]
 >>> semilogy([1.0, 2.3, 3.3],[9.4e-04, 9.4e-05, 9.4e-05]) <---
 >>> work
 Jean-Baptiste> [<matplotlib.lines.Line2D instance at 0x940e964>]
S=E6ll Jean!
Thanks for this example. The relevant code which handles autoscaling
is in matplotlib.axis.autoscale_view. I wasn't handling the special
case where min=3Dmax for log scaling (though I do handle it for linear
scaling).
Try this replacement code for axis.py: and the functions decade_down
and decade_up and replace the autoscale_view function.
def decade_down(x):
 'floor x to the nearest lower decade'
 lx =3D math.floor(math.log10(x))
 return 10**lx
def decade_up(x):
 'ceil x to the nearest higher decade'
 lx =3D math.ceil(math.log10(x))
 return 10**lx
class Axis(Artist):
 def autoscale_view(self):
 'Try to choose the view limits intelligently'
 vmin, vmax =3D self.datalim.bounds()
 if self._scale=3D=3D'linear':
 if vmin=3D=3Dvmax:
 vmin-=3D1
 vmax+=3D1
 try:
 (exponent, remainder) =3D divmod(math.log10(vmax - vmin),=
 1)
 except OverflowError:
 print >>sys.stderr, 'Overflow error in autoscale', vmin, =
vmax
 return
 if remainder < 0.5:
 exponent -=3D 1
 scale =3D 10**(-exponent)
 vmin =3D math.floor(scale*vmin)/scale
 vmax =3D math.ceil(scale*vmax)/scale
 self.viewlim.set_bounds(vmin, vmax)
 elif self._scale=3D=3D'log':
 if vmin=3D=3Dvmax:
 vmin =3D decade_down(vmin)
 vmax =3D decade_up(vmax)
 self.viewlim.set_bounds(vmin, vmax)
Let me know how this works for you,
JDH
From: John H. <jdh...@ac...> - 2004年02月04日 03:12:58
>>>>> "matthew" == matthew arnison <ma...@ca...> writes:
 matthew> Hi again, I'm having more trouble with matplotlib ticks
 matthew> today. I wrote a little demo script that illustrates some
 matthew> of the problems:
Hi Matthew,
Thanks for sending me these example scripts - it really helps to have
complete examples when working on these problems. I've made a few
changes to the tickval formatter. The relevant function is
matplotlib.axis.format_tickval and is pretty simple conceptually.
Try replacing the default format_tickval with this one. The d
variable gives the max-min distance of the view limits. I use
different format strings depending on the size of the distance. 
 def format_tickval(self, x):
 'Format the number x as a string'
 d = self.viewlim.interval()
 if self._scale == 'log':
 # only label the decades
 fx = self.transData.func(x)
 isdecade = abs(fx-int(fx))<1e-10
 if self._ticklabelStrings is None and not isdecade: return ''
 #if the number is not too big and it's an int, format it as an
 #int
 if abs(x)<1e4 and x==int(x): return '%d' % x
 # if the value is just a fraction off an int, use the int
 if abs(x-int(x))<0.0001*d: return '%d' % int(x)
 # use exponential formatting for really big or small numbers,
 # else use float
 if d < 1e-2 : fmt = '%1.2e'
 elif d < 1e-1 : fmt = '%1.2f'
 elif d > 1e5 : fmt = '%1.3e'
 elif d > 10 : fmt = '%1.1f'
 elif d > 1 : fmt = '%1.2f'
 else : fmt = '%1.3f'
 s = fmt % x
 #print d, fmt, x, s
 # strip trailing zeros, remove '+', and handle exponential formatting
 m = self._zerorgx.match(s)
 if m:
 s = m.group(1)
 if m.group(2) is not None: s += m.group(2)
 s = s.replace('+', '')
 return s
And then feed it some more of your sadistic examples <wink>. If you
don't like what you see, try tweaking the formats and the distance
values until you get sensible results. Or feel free to provide more
comments and send more examples.
JDH
From: John H. <jdh...@ac...> - 2004年02月04日 03:05:23
>>>>> "matthew" == matthew arnison <ma...@ca...> writes:
 matthew> Hi, I am happily using matplotlib-0.50e. I tried eps
 matthew> output and it worked very nicely. The problem with plot
 matthew> lines not being clipped by a manual axis in the PS
 matthew> backend also seems to have been fixed.
Good to hear ..
 matthew> I have some feedback on the default tick
 matthew> behaviour. matplotlib seems to pick a number of ticks,
 matthew> and then divides through to get the tick values. This
 matthew> results in some ugly long tick labels, making it hard to
 matthew> quickly gauge the range between two points on a graph.
 matthew> E.g. if the y range of a plot is 1.927 to 1.948, then
 matthew> matplotlib puts ticks at (1.927, 1.931, 1.935, ...,
 matthew> 1.948)
I agree this is an important issue. It's also a difficult one. If
matplotlib just had to make a good choice for the axis limits and tick
values for a single plot, it wouldn't be too hard. What becomes
harder is to do this in the presence of interactivity. Once you allow
the user to pan and zoom, you have some other considerations. For
example, if the tick locations or the number of ticks/grids on the
axis move while you pan or zoom, that is visually disturbing. The
easiest way to optimize the tick locations is to have some flexibility
in choosing the number of ticks, but after the initial plot, this
number is set for the rest of the interactive session which makes it
harder.
So enough excuses! I agree that the current implementation is
suboptimal and will give it some more thought. Out of curiosity: do
the undersirable tick locs appear more frequently for you on an
initial plot or after interacting with the plot.
 matthew> Another slight niggle. If I set the axis range manually,
 matthew> then if a data point is exactly equal to the end of the
 matthew> axis range then it won't be plotted. 
This is a consequence of the way python and Numeric do ranges, and
doesn't really have anything to do with matplotlib. eg, the Numeric
function arange
 >>> from Numeric import *
 >>> arange(0.0, 1.0, 0.2)
 array([ 0. , 0.2, 0.4, 0.6, 0.8])
 >>> range(5)
 [0, 1, 2, 3, 4]
Ie, ignore the end point is the default behavior of python.
JDH
From: John H. <jdh...@ac...> - 2004年02月04日 02:55:31
>>>>> "Jean-Baptiste" == Jean-Baptiste Cazier <Jea...@de...> writes:
 Jean-Baptiste> Hi ! I am using with delight the new object_picker
 Jean-Baptiste> tools as of version 0.42b It works fine but I can
 Jean-Baptiste> not find out how to draw the legend, labels, title,
 Jean-Baptiste> etc... Neither the ax (Subplot), nor the fig
 Jean-Baptiste> (ArtistPickerFigure) have those methods. How could
 Jean-Baptiste> I access them ?
First, I recommend upgrading the 0.50 series as there have been APi
changes that affect the object_picker code (the examples.object_picker
demo script is updated). Better to catch up sooner rather than later.
Second, I don't really understand your question. If you want to "draw
the legend, labels, ...", you simply call the draw method. All of
these things (Legend, Text, etc..) are derived from Artist, which
implements a "draw" method. so you can call
 legend.draw()
 label.draw()
and so on?
Then later you say "those methods" using the plural. I don't know
what you mean..... Could you elaborate, and perhaps provide some code
with comments showing where you are stuck?
Thanks,
JDH

Showing 5 results of 5

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /