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





Showing 10 results of 10

From: John H. <jd...@gm...> - 2008年03月28日 16:17:49
On Fri, Mar 28, 2008 at 8:20 AM, Matthias Michler
<Mat...@gm...> wrote:
> On Friday 28 March 2008 13:57, Chris Withers wrote:
> > Matthias Michler wrote:
> > > I'm not sure it is the easiest way, but it works for me:
> > >
> > > for label in ax.xaxis.get_majorticklabels():
> > > label.set_rotation(+90)
> >
> > Yes, that's what I was using, just wondered if there was a better way...
>
> At least I don't know a better way, but I'm not an expert.
>
>
> > >> Also, how would I get this kind of updating with bar charts or
> > >> errorbars?
> > >
> > > In the case of bar charts and errorbars it is quite difficult to reset
> > > the data.
> >
> > Oh, I also meant to ask about scatter, can the data be easilly reset there?
>
> Scatter returns a line collection and I don't know if there is a method to
> reset their x/ydata.
We do not have good built in support for this kind of thing (though we
should add it). One approach is to write a custom artist, as in this
example. I'm using GTK only for the idle handling callback, but you
can use whatever approach works for you. The important part is the
example showing how to write a custom artist for dynamic data:
import gtk
import numpy as np
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
import matplotlib.artist as artist
import matplotlib.colors as colors
import matplotlib.agg as agg
class DynamicMarkers(artist.Artist):
 def __init__(self, buffersize=30):
 artist.Artist.__init__(self)
 self.buffersize = buffersize
 self.x = []
 self.y = []
 self.count = 0
 self.path = None
 self.markersize = 10.
 self.facecolor = colors.colorConverter.to_rgb('blue')
 self.edgecolor = colors.colorConverter.to_rgb('black')
 def add(self, x, y):
 self.count+=1
 self.x.append(x)
 self.y.append(y)
 if self.count>self.buffersize:
 del self.x[0]
 del self.y[0]
 def draw(self, renderer):
 if self.axes is None:
 raise RuntimeError('you must first add me to the axes')
 if self.path is None:
 # use square markers
 side = renderer.points_to_pixels(self.markersize)
 offset = side*0.5
 path = agg.path_storage()
 path.move_to(-offset, -offset)
 path.line_to(-offset, offset)
 path.line_to(offset, offset)
 path.line_to(offset, -offset)
 path.end_poly()
 self.path = path
 gc = renderer.new_gc()
 self._set_gc_clip(gc) # Artist method
 gc.set_foreground(self.edgecolor)
 renderer.draw_markers(gc, self.path, self.facecolor, self.x,
self.y, self.get_transform())
fig = plt.figure()
ax = fig.add_subplot(111)
myline = DynamicMarkers(30)
ax.add_artist(myline)
ax.set_xlim(-20, 1)
ax.set_ylim(0,1)
def animate(*args):
 i = animate.i
 print 'animate', i
 myline.add(i, np.random.rand())
 ax.set_xlim(i-30, i+1)
 fig.canvas.draw()
 animate.i += 1
 if animate.i<200: return True
 else: return False
gtk.idle_add(animate)
animate.i = 0
plt.show()
From: Ryan D. <rya...@UD...> - 2008年03月28日 15:24:22
Chris Withers wrote:
>> So, basically make the x axis time instead of numbers.
>> I think the problem is actually that the daets are quite long in their
>> format. If they were rotated through 90 degress it'd likely be fine.
>> How would I do this?
> 
> I'm not sure it is the easiest way, but it works for me:
> 
> for label in ax.xaxis.get_majorticklabels():
> label.set_rotation(+90)
To adjust tick labels when using dates, you could also try 
Figure.autofmt_xdate (I added it to the example code you were using 
below). Internally it sets the rotation of the xticklabels as described 
above, but also sets horizontal alignment of the labels and is 
especially useful if you have multiple subplots.
-Ryan
from datetime import datetime
from time import sleep
ion() # interactive mode 'on'
fig = figure()
ax = fig.add_subplot(111, autoscale_on=True)
x, y = [datetime.now()], [0]
line = plot(x, y, label="my_data")[0]
# get the line-object as the first element
# of the tuple returned by plot legend()
for i in arange(30):
 x.append(datetime.now()) # append new values
 y.append(i**2)
 line.set_data(x,y) # reset data
 ax.relim() # reset axes limits
 ax.autoscale_view() # rescale axes
 fig.autofmt_xdate() # adjust the xtick labels
 draw() # redraw current figure
 sleep(0.3) # wait 0.3 seconds
ioff()
show()
From: Chiara C. <chi...@ho...> - 2008年03月28日 13:29:26
I am not sure how should I use it.... any hints?
----------------------------------------
> From: jgo...@gm...
> To: mat...@li...
> Subject: Re: [Matplotlib-users] Polygon masking possible?
> Date: 2008年3月14日 18:03:13 +0000
> CC: chi...@ho...
> 
> On Friday 14 March 2008 16:44:54 Chiara Caronna wrote:
>> I tried ds9 and It looks like this is what I would like to do (though I
>> couldn't try funtools, but what you describe is good). DO you think it is
>> possible to make something like this with matplotlib? Thanks a lot for your
> 
> The initiating thread (from January) had some suggestions. In particular, some 
> code that does this from Rob Hetland: 
> 
> 
> Hope that helps,
> Jose
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
From: Matthias M. <Mat...@gm...> - 2008年03月28日 13:20:49
On Friday 28 March 2008 13:57, Chris Withers wrote:
> Matthias Michler wrote:
> > I'm not sure it is the easiest way, but it works for me:
> >
> > for label in ax.xaxis.get_majorticklabels():
> > label.set_rotation(+90)
>
> Yes, that's what I was using, just wondered if there was a better way...
At least I don't know a better way, but I'm not an expert.
> >> Also, how would I get this kind of updating with bar charts or
> >> errorbars?
> >
> > In the case of bar charts and errorbars it is quite difficult to reset
> > the data.
>
> Oh, I also meant to ask about scatter, can the data be easilly reset there?
Scatter returns a line collection and I don't know if there is a method to 
reset their x/ydata.
> For bar charts and errorbar plots, I agree ;-) How would I just blank
> the figure and replot?
I'm not sure, but maybe clf() to clear the whole figure and cla() to clear the 
axes does the job.
> (I have just been calling errorbar lots, but I'm guessing that if I add
> a legend, I'll have one entry for each time I called errorbar :-S)
regards,
Matthias
From: Chris W. <ch...@si...> - 2008年03月28日 12:57:32
Matthias Michler wrote:
> I'm not sure it is the easiest way, but it works for me:
> 
> for label in ax.xaxis.get_majorticklabels():
> label.set_rotation(+90)
Yes, that's what I was using, just wondered if there was a better way...
>> Also, how would I get this kind of updating with bar charts or errorbars?
> 
> In the case of bar charts and errorbars it is quite difficult to reset the 
> data. 
Oh, I also meant to ask about scatter, can the data be easilly reset there?
For bar charts and errorbar plots, I agree ;-) How would I just blank 
the figure and replot?
(I have just been calling errorbar lots, but I'm guessing that if I add 
a legend, I'll have one entry for each time I called errorbar :-S)
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Lionel R. <lro...@li...> - 2008年03月28日 11:13:11
You can use the scipy version:
|~|[10]>from scipy.stats import stats
|~|[11]>stats.scoreatpercentile(x,50)
Out [11]:7.5
Le vendredi 28 mars 2008, David Simpson a écrit :
> I would like to find percentiles, with interpolation where needed, but
> the matplotlib prctile seems to be different to matlab in this respect:
>
> In [1]: x = array([ 3.0, 5.0, 7.0, 8.0, 9.0, 11.0 ])
>
> In [2]: median(x)
> Out[2]: 7.5
>
> In [3]: prctile(x,50)
> Out[3]: 8.0
>
>
> is there a function available which does include interpolation, or
> should I just write my own? (I'd also like 10th and 90th percentiles for
> example).
>
> Thanks, Dave
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplac
>e _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
Lionel Roubeyrie - lro...@li...
Chargé d'études et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr
From: David S. <dav...@rs...> - 2008年03月28日 10:52:54
I would like to find percentiles, with interpolation where needed, but 
the matplotlib prctile seems to be different to matlab in this respect:
In [1]: x = array([ 3.0, 5.0, 7.0, 8.0, 9.0, 11.0 ])
In [2]: median(x)
Out[2]: 7.5
In [3]: prctile(x,50)
Out[3]: 8.0
is there a function available which does include interpolation, or 
should I just write my own? (I'd also like 10th and 90th percentiles for 
example).
Thanks, Dave
From: Matthias M. <Mat...@gm...> - 2008年03月28日 09:46:32
Hello Chris,
Hello list,
On Thursday 27 March 2008 18:26, Chris Withers wrote:
> Matthias Michler wrote:
> > I'm not sure that I understand you correctly. The code I refering is the
> > one which I attached some mails ago. The following works for me:
>
> Ah, okay, to get the problem I was having, change your script as follows:
> > -------------------------------------------------------------------------
> >-------- from pylab import *
> >
> > from datetime import datetime
> >
> > from time import sleep
> >
> > ion() # interactive mode 'on'
> > figure()
> > ax = subplot(111, autoscale_on=True)
> >
> > x, y = [datetime.now()], [0]
> > line = plot(x, y, label="my_data")[0]
> > # get the line-object as the first
> > element # of the tuple returned by plot legend()
> > for i in arange(30):
> > x.append(datetime.now()) # append new values
> > y.append(i**2)
> > line.set_data(x,y) # reset data
> > ax.relim() # reset axes limits
> > ax.autoscale_view() # rescale axes
> > draw() # redraw current figure
> > sleep(0.3) # wait 0.3 seconds
> >
> > ioff()
> > show()
>
> So, basically make the x axis time instead of numbers.
> I think the problem is actually that the daets are quite long in their
> format. If they were rotated through 90 degress it'd likely be fine.
> How would I do this?
I'm not sure it is the easiest way, but it works for me:
for label in ax.xaxis.get_majorticklabels():
 label.set_rotation(+90)
> Also, how would I get this kind of updating with bar charts or errorbars?
In the case of bar charts and errorbars it is quite difficult to reset the 
data. 
e.g. errobar (from the docstring) 
Return value is a length 3 tuple. The first element is the
 Line2D instance for the y symbol lines. The second element is
 a list of error bar cap lines, the third element is a list of
 line collections for the horizontal and vertical error ranges
I think it is quite expensive to reset all x/ydata of the lines by yourself 
and I have no idea how to reset data of line collections.
I would replot the errorbars, but maybe somebody else knows a good way to 
reset the data of errorbars.
regards 
Matthias
From: John <was...@gm...> - 2008年03月28日 01:03:27
Hello, could someone please help me understand a strange problem, possibly
associated with PYTHONPATH. When I import matplotlib, pylab, or scipy from
any directory other than the root installation directory, it fails. However,
if I'm in the python installation directory there are no errors. Thanks in
advance! Please see below:
*[jfb@andLinux ~]$ python*
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib/python2.5/site-packages/scipy/__init__.py", line 18, in
<module>
 import pkg_resources as _pr # activate namespace packages (manipulates
__path__)
 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581, in
<module>
 add_activation_listener(lambda dist: dist.activate())
 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 640, in
subscribe
 callback(dist)
 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581, in
<lambda>
 add_activation_listener(lambda dist: dist.activate())
 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2130, in
activate
 map(declare_namespace, self._get_metadata('namespace_packages.txt'))
 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1749, in
declare_namespace
 _handle_ns(packageName, path_item)
 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1712, in
_handle_ns
 module = sys.modules[packageName] = new.module(packageName)
AttributeError: 'module' object has no attribute 'module'
>>>
*[jfb@andLinux ~]$ cd /usr/lib/python2.5/
[jfb@andLinux python2.5]$ python*
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>>
*[jfb@andLinux python2.5]$ cd
[jfb@andLinux ~]$ echo $PYTHONPATH*
:.:/usr/lib/python2.5/:.:/home/jfb/bin
*[jfb@andLinux ~]$*
From: Andrew C. <ac...@gm...> - 2008年03月28日 00:09:40
Attachments: test_case.py
Quiver doesn't seem to be able to handle begin passed zeros for the
vector lengths. The full error output is below. I'm running Leopard
with macpython 2.5.2 using
matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg
The following code does not work:
rx = numpy.array([0.0,0.0])
ry = numpy.array([1.0,-1.0])
ax = numpy.array([0.0,0.0])
ay = numpy.array([0.0,0.0])
quiver(rx,ry,ax,ay)
savefig("image2.png",format='png')
The same code works if any of ax or ay are nonzero.
Cheers,
Andrew Charles
-----------------------------------
Error output:
spinode: ./test_case.py
Traceback (most recent call last):
 File "./test_case.py", line 24, in <module>
 savefig("image2.png",format='png')
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/pyplot.py",
line 269, in savefig
 return fig.savefig(*args, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/figure.py",
line 782, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/backends/backend_wxagg.py",
line 101, in print_figure
 FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/backend_bases.py",
line 1201, in print_figure
 self.figure.canvas.draw()
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/backends/backend_wxagg.py",
line 61, in draw
 FigureCanvasAgg.draw(self)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/backends/backend_agg.py",
line 358, in draw
 self.figure.draw(self.renderer)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/figure.py",
line 624, in draw
 for a in self.axes: a.draw(renderer)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/axes.py",
line 1345, in draw
 a.draw(renderer)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/quiver.py",
line 336, in draw
 verts = self._make_verts(self.U, self.V)
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.3-i386.egg/matplotlib/quiver.py",
line 386, in _make_verts
 length = a/(self.scale*self.width)
 File "/Library/Python/2.5/site-packages/numpy/ma/core.py", line
1679, in __div__
 return divide(self, other)
 File "/Library/Python/2.5/site-packages/numpy/ma/core.py", line 614,
in __call__
 numpy.putmask(d2, t, self.filly)

Showing 10 results of 10

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