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






Showing 4 results of 4

From: John H. <jd...@gm...> - 2007年09月28日 12:41:43
On 9/27/07, Charles Seaton <cs...@st...> wrote:
> I am having the same problem as Eugen, and the suggested solution of using
> a.xaxis.get_major_locator().refresh()
> to force the creation of the full set of ticklabels doesn't seem to work for
> me.
matplotlib creates a prototypical tick (the prototick) and then
creates new ones on as as needed basis, copying properties from the
prototick. Of course, position is one of the properties that cannot
be copied, which is why you are having trouble in your example.
Fortunately, there is an easy solution.
Call ax.xaxis.get_major_ticks() and access the label attribute:
for tick in ax.xaxis.get_major_ticks():
 label = tick.label1
Axis.get_major_ticks will force a call to the locator and update the
tick list. The Axes methods like get_xticklabels are just working on
the existing tick list rather than calling the get_major_ticks method
which is why you are not getting the full list. This is a bug. I
just made changes in svn so that all the accessor methods
(ax.get_xticklines, ax.get_yticklabels, and friends) all trigger a
call to axis.get_major_ticks rather so they should give the same
results going forward.
JDH
FYI, the Tick attributes are:
 tick1line : a Line2D instance
 tick2line : a Line2D instance
 gridline : a Line2D instance
 label1 : a Text instance
 label2 : a Text instance
 gridOn : a boolean which determines whether to draw the tickline
 tick1On : a boolean which determines whether to draw the 1st tickline
 tick2On : a boolean which determines whether to draw the 2nd tickline
 label1On : a boolean which determines whether to draw tick label
 label2On : a boolean which determines whether to draw tick label
From: Darren D. <dd...@co...> - 2007年09月28日 12:23:34
On Friday 28 September 2007 07:36:23 am John Hunter wrote:
> On 9/27/07, Darren Dale <dd...@co...> wrote:
> > Hi Eric, John,
> >
> > Have either of you been following this thread?
>
> I am now :-)
>
> As Eric suggests, None is overloaded vis-a-vis color handling, because
> for mpl properties it generally means do the default as defined by rc.
> For colors people often want to use None for "no color" which is why
> we added support for the string "None". Does this work in your use
> case Tom?
The above exchange was off-list, we're back on now. I think that would be what 
Tom is looking for, but it doesnt work:
In [1]: plot([1,2])
Out[1]: [<matplotlib.lines.Line2D instance at 0x710cb0>]
In [2]: savefig('dsd.png', facecolor='None', edgecolor='None')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/darren/<ipython console> in <module>()
/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py in savefig(*args, 
**kwargs)
 272 def savefig(*args, **kwargs):
 273 fig = gcf()
--> 274 return fig.savefig(*args, **kwargs)
 275 if Figure.savefig.__doc__ is not None:
 276 savefig.__doc__ = dedent(Figure.savefig.__doc__)
/usr/lib64/python2.5/site-packages/matplotlib/figure.py in savefig(self, 
*args, **kwargs)
 768 kwargs[key] = rcParams['savefig.%s'%key]
 769
--> 770 self.canvas.print_figure(*args, **kwargs)
 771
 772 def colorbar(self, mappable, cax=None, **kw):
/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py in 
print_figure(self, *args, **kwargs)
 153 self.update(l, self.renderer.height-t, w, h)
 154
 155 def print_figure(self, *args, **kwargs):
--> 156 FigureCanvasAgg.print_figure(self, *args, **kwargs)
 157 self.draw()
/usr/lib64/python2.5/site-packages/matplotlib/backend_bases.py in 
print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, 
**kwargs)
 1194 edgecolor=edgecolor,
 1195 orientation=orientation,
-> 1196 **kwargs)
 1197 finally:
 1198 self.figure.dpi.set(origDPI)
/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py in 
print_png(self, filename, *args, **kwargs)
 415
 416 def print_png(self, filename, *args, **kwargs):
--> 417 self.draw()
 418 self.get_renderer()._renderer.write_png(str(filename))
 419
/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py in 
draw(self)
 140 if DEBUG: print "FigureCanvasQtAgg.draw", self
 141 self.replot = True
--> 142 FigureCanvasAgg.draw(self)
 143 self.update()
 144
/usr/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py in 
draw(self)
 377
 378 self.renderer = self.get_renderer()
--> 379 self.figure.draw(self.renderer)
 380
 381 def get_renderer(self):
/usr/lib64/python2.5/site-packages/matplotlib/figure.py in draw(self, 
renderer)
 586 self.transFigure.freeze() # eval the lazy objects
 587
--> 588 if self.frameon: self.figurePatch.draw(renderer)
 589
 590 for p in self.patches: p.draw(renderer)
/usr/lib64/python2.5/site-packages/matplotlib/patches.py in draw(self, 
renderer)
 198 #renderer.open_group('patch')
 199 gc = renderer.new_gc()
--> 200 gc.set_foreground(self._edgecolor)
 201 gc.set_linewidth(self._linewidth)
 202 gc.set_alpha(self._alpha)
/usr/lib64/python2.5/site-packages/matplotlib/backend_bases.py in 
set_foreground(self, fg, isRGB)
 617 self._rgb = fg
 618 else:
--> 619 self._rgb = colors.colorConverter.to_rgb(fg)
 620
 621 def set_graylevel(self, frac):
/usr/lib64/python2.5/site-packages/matplotlib/colors.py in to_rgb(self, arg)
 277
 278 except (KeyError, ValueError, TypeError), exc:
--> 279 raise ValueError('to_rgb: Invalid rgb arg "%s"\n%s' % 
(str(arg), exc))
 280 # Error messages could be improved by handling TypeError
 281 # separately; but this should be rare and not too hard
ValueError: to_rgb: Invalid rgb arg "None"
invalid literal for float(): None
From: Alan G I. <ai...@am...> - 2007年09月28日 04:13:47
After thinking it over, I did not go for
Robert or David's cool numpy tricks, but
I'll append a simple object in case someone
else wants to do more.
Cheers,
Alan Isaac
class EmpiricalCDF(object):
 '''Empirical cdf.
 First point will be (xmin,0).
 Last point will be (xmax,1).
 '''
 def __init__(self, data, sortdata=True):
 if sortdata:
 data = N.sort(data)
 self.data = data
 self.nobs = len(data)
 def gen_xp(self):
 data, nobs = self.data, self.nobs
 prob = N.linspace(0, 1, nobs+1)
 xsteps = ( data[(idx)//2] for idx in xrange(2*nobs) )
 psteps = ( prob[(idx+1)//2] for idx in xrange(2*nobs) )
 return xsteps, psteps
 def get_steps(self):
 '''Return: 2-tuple of arrays,
 the data values and corresponding cumulative 
 probabilities.
 '''
 xsteps, psteps = self.gen_xp()
 return N.fromiter(xsteps,'f'), N.fromiter(psteps,'f')
From: Eric F. <ef...@ha...> - 2007年09月28日 00:46:54
Hal Huntley wrote:
> Thanks to Eric Firing and Christopher Barker for input on trying to
> resolve the problem. Christopher said:
> %%%
> You might try just:
> 
> easy_install numpy
> 
> easy_install matplotlib.
> %%%
> 
> 
> I did that and now the problem moved and I get:
> ===
>>>> from pylab import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/pylab.py", line 1, in ?
> from matplotlib.pylab import *
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/pylab.py", line 222, in ?
> new_figure_manager, draw_if_interactive, show = pylab_setup()
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/__init__.py", line 24, in pylab_setup
> globals(),locals(),[backend_name])
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/backend_gtkagg.py", line 10, in ?
> from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK,
> FigureCanvasGTK,\
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/backend_gtk.py", line 21, in ?
> from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
> File
> "/usr/lib/python2.4/site-packages/matplotlib-0.90.1-py2.4-linux-i686.egg/matplotlib/backends/backend_gdk.py", line 35, in ?
> from matplotlib.backends._ns_backend_gdk import pixbuf_get_pixels_array
> ImportError: No module named _ns_backend_gdkd4
> ===
Is it a rotten egg?
> 
> Googling around has indicated that the X11 stuff wasn't available when the
> numpy and matplotlib were made. The gtk files and "-devel" seem to be there
> when I do an "rpm -qa". I went and got a new numpy from source and did
> "python setup.py install". It is interesting that when I get in to python
> now, I can do:
> 
>>>> import gtk
>>>> import numpy
>>>> import matplotlib
> 
> and they all just return the prompt, indicating, I thought, that the
> programs were installed ok. 
> 
> Here is the naive question -> Is there something wrong, then with a
> "from pylab import *"? The user is trying to do that. 
No, that should work fine. I don't know how the egg-based 
matplotlib/pylab should work with the installed-from-source numpy, 
though. If the versions are compatible, then I expect it would work.
You gave a traceback resulting from "from pylab import *" after 
installing the two eggs, correct? If so, what was the result after you 
installed numpy from source? I would expect no difference, because the 
problem reported in the traceback is a missing matplotlib module, not a 
missing numpy module.
Or did you mean that you installed matplotlib from source? That would 
make more sense, and certainly should work if all the right header files 
and libraries are present.
If you installed matplotlib from source, what do you get from
ls /usr/lib/python2.4/site-packages/matplotlib/backends/*.so
Another diagnostic would be to delete the build directory from the 
matplotlib source tree (assuming you are now building matplotlib from 
source), and save the output from the "python setup.py build" command. 
This should make it clear whether the necessary headers really were found.
Eric

Showing 4 results of 4

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