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

Showing 14 results of 14

From: John H. <jdh...@ac...> - 2005年12月21日 23:35:06
>>>>> "Alan" == Alan G Isaac <ai...@am...> writes:
 Alan> In pylab: just choose the number of bins. Hope this helps.
 Alan> Alan Isaac
 >>>> import pylab as P help(P.hist)
 Alan> Help on function hist in module matplotlib.pylab:
If you know your data are integers, you might get nicer results by
specifying the bins rather than autogenerating them by passing in
number of bins. Eg for a 12 sided dice
 import matplotlib.numerix as nx
 bins = nx.arange(1,13)
 n,bins,patches = P.hist(throws, bins)
JDH
From: Alan G I. <ai...@am...> - 2005年12月21日 23:15:57
In pylab: just choose the number of bins.
Hope this helps.
Alan Isaac
>>> import pylab as P
>>> help(P.hist)
Help on function hist in module matplotlib.pylab:
hist(*args, **kwargs)
 HIST(x, bins=3D10, normed=3D0, bottom=3D0, orientiation=3D'vertical', *=
*kwargs)
 Compute the histogram of x. bins is either an integer number of
 bins or a sequence giving the bins. x are the data to be binned.
 The return values is (n, bins, patches)
 If normed is true, the first element of the return tuple will be the
 counts normalized to form a probability distribtion, ie,
 n/(len(x)*dbin)
 orientation =3D 'horizontal' | 'vertical'. If horizontal, barh
 will be used and the "bottom" kwarg will be the left.
 kwargs are used to update the properties of the
 hist bars
 Addition kwargs: hold =3D [True|False] overrides default hold state
>>>
From: Peter B. <pe...@ma...> - 2005年12月21日 23:09:21
Hi,
I have a data set (number of dice thrown showing a particular number) 
and I'm trying to create a histogram of it. The data is stored in a 
text file, one trial per line, and I'm loading it using load().
Sample data:
12
17
8
12
11
16
It appears I need to group the data somehow into counts, eg:
8 : 1
9 : 0
10 : 0
11 : 1
12 : 2
and so on...
Is there a way to do this in matplotlib or am I missing something 
about hist() or one of the other functions?
Thanks,
Peter
From: Jouni K S. <jk...@ik...> - 2005年12月21日 17:03:16
Steve Schmerler <el...@gm...> writes:
> 	plot(..., label = r'$x^2 = $' + str(3))
>
> produces labels like $x^2 = 3ドル
>
> I think this is because I try to join a "normal" string and a "raw"
> string. Is there a way to do this properly?
The raw-ness is not relevant to the problem; the only thing it does it
prevent special interpretation of backslashes. What is "raw" is the
string literal in your file, not the string value.
You need to keep the dollar signs at the beginning and end. What you
want is the percent-sign operator:
 label = r'$x^2 = %d$' % 3
-- 
Jouni
From: John H. <jdh...@ac...> - 2005年12月21日 14:02:30
I recently spent some time trying to debug what I thought was a memory
leak in matplotlib. I had added tried all sorts of shenanigans to
make sure my memory was freed and the memory collected, but the leak
persisted. I had written code like
for i in somerange:
 fig = figure()
 ...
 fig.savefig(somefile)
 del fig
 gc.collect()
I eventually realized/remembered why this fails: because pylab manages
figures behind the scenes (eg managing the current figure) there is a
dictionary in _pylab_helpers that retains a reference to the figure.
Calling close on the figure removes this reference, so all I really
needed to do was
for i in somerange:
 fig = figure()
 ...
 fig.savefig(somefile)
 close(fig)
and pylab handles the call to gc.collect.
Just a reminder to myself and you all, that even though it looks like
a fig is not being referenced in your local code, there are still
references to it in pylab so if you're using pylab you should balance
each call to figure with a call to close.
JDH
From: John H. <jdh...@ac...> - 2005年12月21日 12:38:42
>>>>> "Jiri" == Jiri Polcar <po...@ph...> writes:
 Jiri> On Tue, Dec 20, 2005 at 07:16:33PM -0600, John Hunter wrote:
 >> Just set the xscale attribute for the axes to be 'log' (and
 >> make sure you have strictly positive data, of course)
 >> 
 >> ax = subplot(111, xscale='log') ax.hist(X, 100)
 >> 
 Jiri> It works. Thanke you very mych. But if I want to set
 Jiri> logaritmic Y-axes also:
 Jiri> ax = subplot(111, xscale='log', yscale='log' )
 Jiri> I get:
My guess is that this is caused by having a histogram bin with no
values, and the log of 0 is undefined. It would be nice if we could
fix this code to be fault tolerant to invalid data, as we did for line
data.
You can inspect the hist output by doing
 n, bins = matplotlib.mlab.hist(X, 100)
and then seeing what the minimum n is. If it is 0, that is likely to
be the source of your troubles,
 Jiri> PS: 'X' contais whole nubers >= 1.
You might try setting the bins manually to workaround this problem, eg
define the bins such that there are no empty bins.
 mybins = nx.arange(1,20)
 n, bins = matplotlib.mlab.hist(X, bins)
Note that matplotlib.mlab.hist is the non-plotting version of hist
that actually computes the histogram. 
JDH
From: Steve S. <el...@gm...> - 2005年12月21日 12:38:39
Hi
I have a problem when joining 2 strings in a label:
	plot(..., label = r'$x^2$')
works, but
	plot(..., label = r'$x^2 = $' + str(3))
produces labels like $x^2 = 3ドル
I think this is because I try to join a "normal" string and a "raw" 
string. Is there a way to do this properly?
cheers,
steve
-- 
Should array indices start at 0 or 1? My compromise of 0.5 was rejected 
without, I thought, proper consideration.
-- Stan Kelly-Bootle
From: Jiri P. <po...@ph...> - 2005年12月21日 09:16:23
On Tue, Dec 20, 2005 at 07:16:33PM -0600, John Hunter wrote:
> 
> Just set the xscale attribute for the axes to be 'log' (and make sure
> you have strictly positive data, of course)
> 
> ax = subplot(111, xscale='log')
> ax.hist(X, 100)
> 
It works. Thanke you very mych. But if I want to set logaritmic Y-axes
also:
 ax = subplot(111, xscale='log', yscale='log' )
I get:
 Traceback (most recent call last):
 File "bin/plot_msg_len_dist.py", line 22, in ?
 savefig( 'smith_msg_length_dist.png' )
 File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 791,
 in savefig
 return fig.savefig(*args, **kwargs)
 File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
 645, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File
 "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py",
 line 93, in print_figure
 try: agg.print_figure(filename, dpi, facecolor, edgecolor,
 orientation)
 File
 "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
 line 445, in print_figure
 self.draw()
 File
 "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
 line 382, in draw
 self.figure.draw(renderer)
 File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
 520, in draw
 for a in self.axes: a.draw(renderer)
 File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1402,
 in draw
 a.draw(renderer)
 File "/usr/lib/python2.4/site-packages/matplotlib/patches.py", line
 127, in draw
 tverts = self._transform.seq_xy_tups(verts)
 ValueError: Domain error on nonlinear Transformation::seq_xy_tups
 operator()(thisx, thisy)
 make: *** [smith_msg_length_dist.png] Error 1
PS: 'X' contais whole nubers >= 1.
--
JP
From: John H. <jdh...@ac...> - 2005年12月21日 03:28:11
>>>>> "Ken" == Ken McIvor <mc...@ii...> writes:
 Ken> The OO API is "the" interface to matplotlib in that it *is*
 Ken> matplotlib... 
If matplotlib had a QOTW .... :-)
JDH
From: John H. <jdh...@ac...> - 2005年12月21日 01:45:41
>>>>> "Ben" == Ben Jefferys <ben...@im...> writes:
 Ben> "/bmm/scratch/brj03/python-latest/lib/python2.4/site-packages/matplotlib/font_manager.py",
 Ben> line 39, in ? from matplotlib import ft2font ImportError:
 Ben> /bmm/scratch/brj03/python-latest/lib/python2.4/site-packages/matplotlib/ft2font.so:
 Ben> undefined symbol:
 Ben> _ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_jc
 Ben> There seem to be problems with the ft2font.so library. Can
 Ben> anyone help?
This looks a little like either a C++ name mangling issue (could you
have used two different versions of g++ in the compiling of mpl or
it's dependencies) or else a discrepancy between which freetype
include headers are found and which libraries you are linking with.
Nadia was working on a patch to statically include freetype and
similar libs. STScI folks: is this still in the works?
JDH
From: John H. <jdh...@ac...> - 2005年12月21日 01:41:21
>>>>> "Chris" == Chris Fonnesbeck <fon...@gm...> writes:
 Chris> I notice that when generating several plots, they are
 Chris> cascaded upon one another, one slightly to the right and
 Chris> below of the previous one. However, when the plots get
 Chris> near the bottom of the screen, they keep cascading even
 Chris> when only the top of the plot can be seen. Should the
 Chris> cascading not reset when the *bottom* of a frame touches
 Chris> the bottom of the screen, and not the top?
 Chris> Also, when the previous plot disappears prior to the
 Chris> current plot, is there any need to cascade them at all?
 Chris> Currently, the plots cascade even when prior plots have
 Chris> disappeared.
Me thinks this is backend dependent behavior, since we don't do
anything explicit here we fall back on the default behavior for each
backend. Backend dependent patches welcome!
JDH
From: John H. <jdh...@ac...> - 2005年12月21日 01:39:33
>>>>> "James" == James Boyle <bo...@ll...> writes:
 James> Ken - Thanks very much or the quick reply - but the problem
 James> is more fundamental:
Hey Jim,
Thanks for the bug report. I just fixed this in CVS. Give it a test
drive.
Checking in lib/matplotlib/dates.py;
/cvsroot/matplotlib/matplotlib/lib/matplotlib/dates.py,v <--
dates.py
new revision: 1.14; previous revision: 1.13
JDH
From: John H. <jdh...@ac...> - 2005年12月21日 01:30:30
>>>>> "Jouni" == Jouni K Seppanen <jk...@ik...> writes:
 Jouni> John Hunter <jdh...@ac...> writes:
 >> To just make clear, the tick.* properties in rc have now been
 >> replaced by xtick.* and ytick.*. If you don't update your rc
 >> file, you'll get lots of warnings when you start matplotlib.
 Jouni> On a related note, how about allowing multiple groups when
 Jouni> calling matplotlib.rc? Now we need to do something like
 Jouni> rc('xtick', **{'major.pad': 2.0, 'major.size': 2.0,
 Jouni> 'labelsize': 6.0}) rc('ytick', **{'major.pad': 2.0,
 Jouni> 'major.size': 2.0, 'labelsize': 6.0})
 Jouni> which is a bit of a nuisance compared to just calling rc
 Jouni> for 'tick'. Perhaps next someone wants to set the
 Jouni> properties separately for all four borders of the axes, and
 Jouni> then we need four calls?
 Jouni> (Also, aliases for the names with dots would be nice, so
 Jouni> the key=value notation could be used in the call.)
 Jouni> The following patch allows calling rc like
 Jouni> rc(('xtick','ytick'), ...)
Thanks Jouni,
I just applied this to CVS. A minor nit. matplotlib tests for
strings with the is_string_like function which is a bit more robust
than testing for isinstance. Normally, one grabs this from
matplotlib.cbook, but since you patch is for __init__.py, I just did a
cut-and-paste job to put it there as well.
JDH
From: John H. <jdh...@ac...> - 2005年12月21日 01:24:11
>>>>> "Jiri" == Jiri Polcar <po...@ph...> writes:
 Jiri> Hallo, I have (another) simple question. How can I make
 Jiri> logaritmic histogram? If I use ( X is an array of input
 Jiri> data ):
 Jiri> from pylab import * logX = log10( X ) n, bins, patches =
 Jiri> hist( logX, 50 ) show()
 Jiri> I must take a special care for x-axis labels. Is possible to
 Jiri> use semilogx()? How?
Just set the xscale attribute for the axes to be 'log' (and make sure
you have strictly positive data, of course)
 ax = subplot(111, xscale='log')
 ax.hist(X, 100)
JDH

Showing 14 results of 14

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