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

Showing results of 352

<< < 1 .. 7 8 9 10 11 .. 15 > >> (Page 9 of 15)
From: Jeff W. <js...@fa...> - 2005年09月09日 14:37:23
Nicolas Girard wrote:
>On Friday 09 September 2005 15:01, Jeff Whitaker wrote:
> 
>
>>Nicolas: I believe that should be fmt='%1.3f'.
>>
>> 
>>
>Jeff,
>once again, you were tight : thanks for your support !
>
>May I suggest that the documentation for contour() contains fmt='%1.3f' 
>instead of fmt='1.3f' ?
>
>cheers,
>Nicolas
> 
>
Someone beat me to it - it already reads that way in CVS.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: John H. <jdh...@ac...> - 2005年09月09日 14:07:58
>>>>> "Sascha" == Sascha <sas...@gm...> writes:
 Message> For importing External Method in Zope, what is the module
 Message> to
 Sascha> import?
 Sascha> Create a file (e.g. mpl.py) in INSTANCEHOME\Extensions.
Hey Sascha, thanks for this example. If you get some time, could you
add it to the matplotlib wiki at
http://www.scipy.org/wikis/topical_software/MatplotlibCookbook?
I have one suggestion: you need to be careful to do
import matplotlib
matplotlib.use('Agg')
*before* importing pylab, in case the default matplotlibrc setting has
a GUI backend (eg 'backend : GTKAgg')
Thanks!
JDH
From: John H. <jdh...@ac...> - 2005年09月09日 14:05:09
>>>>> "Travis" == Travis Brady <td...@fa...> writes:
 Travis> Anybody know how to update the Matplotlib distribution
 Travis> contained within the Enthought Python distribution? There
 Travis> seems to be no uninstaller for any of the packages and I'd
 Travis> like to update to the latest mpl.
You can simply remove site-packages/matplotlib and then run the
installer from the matplotlib web site.
JDH
From: John H. <jdh...@ac...> - 2005年09月09日 14:04:17
>>>>> "Martin" == Martin Richter <law...@gm...> writes:
 Martin> Then I wondered 'Why is this so?' and figured out that the
 Martin> plot()-command (in interactive mode) plots the previous
 Martin> points all over again with each new point. Therefore
 Martin> using setp(line, data=('old data + new point')) made
 Martin> everything faster because now was only one object to
 Martin> handle (which of course is getting complexer and
 Martin> complexer). Up to this point it is exactly the same as
 Martin> described in 'anim.py'.
 Martin> My question is now: Is there a way just to add points to a
 Martin> plot? Because even in the append-method MPL draws
This is one area of the code I have been actively developing in the
last few months -- the ability to selectively draw certain artists and
reblit just a region of the figure. For a tutorial introduction, see
http://www.scipy.org/wikis/topical_software/MatplotlibCookbook
I'll include an example script below. For each marker, an object is
created, but we only draw each marker once so it is much faster than
the typical case when you get an accumulation of independent objects
and all have to be redrawn. I realize the code is complex and not
suitable for use by your students. This was only meant to be a low
level API that we could then provide a user friendly wrapper around.
But since these features are very new (only in CVS and only for TKAgg,
GTKAgg and WXAgg) we haven't gotten to the stage of making it easy to
use. If you have some ideas on an API to make this more friendly,
please share them.
In the example code below on my system (GTKAgg, 3GHz P4, linux) I get
about 134 PPS (points per second) for both N=100 and N=10000 so it
scales fine. However, for 10000 points, 134 PPS is still pretty slow,
because it takes 74 seconds to finish. For large numbers of points,
you can speed it up significantly by only blitting when a certain
number of points have been drawn, eg replacing the blit code with
 if update.cnt%50==0: ax.figure.canvas.blit(ax.bbox)
With this approach, I draw about 1000 PPS on my machine
Here is the example
import time
import matplotlib.numerix as nx
from matplotlib.patches import Circle
from matplotlib.transforms import identity_transform
from pylab import figure, show
N = 100
x = nx.arange(float(N))
y = nx.mlab.rand(N)
fig = figure()
ax = fig.add_subplot(111, autoscale_on=False)
ax.set_xlim(0,N)
ax.set_ylim(-.1, 1.1)
radius = 6/72.*ax.figure.dpi.get() # 6 points in pixels
def update(*args):
 # we want to draw a circle at x,y in data coordinates but have the
 # radius in pyhysical size (points). To accomplish this we use an
 # identity transform and draw a circle at 0,0 with a radius in
 # pixels. We apply an translation offset of x,y in data coords
 if update.cnt==0:
 update.start = time.time()
 trans = identity_transform()
 trans.set_offset( (x[update.cnt], y[update.cnt]), ax.transData)
 circ = Circle( (0,0), radius=radius, transform=trans )
 circ.set_clip_box(ax.bbox)
 #selectively draw the artist with the draw_artist command
 #and just reblit the axes bounding box
 ax.draw_artist(circ)
 ax.figure.canvas.blit(ax.bbox)
 update.cnt+=1
 if update.cnt==len(x):
 print 'PPS', update.cnt/(time.time()-update.start)
 return False
 else: return True
update.cnt=0
# use any GUI timer or idle function you want
import gobject
gobject.idle_add(update)
show()
If you do want to blit every marker when it is created, you can reblit
just the small region that bounds the marker. The "get_window_extent"
call is a bbox that bounds the circle vertices, but you have to pad it
a little to account for the line width. The relevant update is
 l,b,w,h = circ.get_window_extent().get_bounds()
 pad = 3
 bbox = lbwh_to_bbox(l-pad, b-pad, w+2*pad, h+2*pad)
 ...snip...
 ax.figure.canvas.blit(bbox)
which gives me 777 PPS even when blitting every marker.
Here is the complete example
import time
import matplotlib.numerix as nx
from matplotlib.patches import Circle
from matplotlib.transforms import identity_transform, lbwh_to_bbox
from pylab import figure, show
N = 10000
x = nx.arange(float(N))
y = nx.mlab.rand(N)
fig = figure()
ax = fig.add_subplot(111, autoscale_on=False)
ax.set_xlim(0,N)
ax.set_ylim(-.1, 1.1)
radius = 6/72.*ax.figure.dpi.get() # 6 points in pixels
def update(*args):
 if update.cnt==0:
 update.start = time.time()
 trans = identity_transform()
 trans.set_offset( (x[update.cnt], y[update.cnt]), ax.transData)
 circ = Circle( (0,0), radius=radius, transform=trans )
 circ.set_clip_box(ax.bbox)
 l,b,w,h = circ.get_window_extent().get_bounds()
 pad = 3
 bbox = lbwh_to_bbox(l-pad, b-pad, w+2*pad, h+2*pad)
 ax.draw_artist(circ)
 ax.figure.canvas.blit(bbox)
 update.cnt+=1
 if update.cnt==len(x):
 print 'PPS', update.cnt/(time.time()-update.start)
 return False
 else: return True
update.cnt=0
import gobject
gobject.idle_add(update)
show()
From: Nicolas G. <nic...@ne...> - 2005年09月09日 13:59:15
On Friday 09 September 2005 15:01, Jeff Whitaker wrote:
> Nicolas: I believe that should be fmt='%1.3f'.
>
Jeff,
once again, you were tight : thanks for your support !
May I suggest that the documentation for contour() contains fmt='%1.3f' 
instead of fmt='1.3f' ?
cheers,
Nicolas
From: Martin R. <law...@gm...> - 2005年09月09日 13:10:56
Hello everyone,
I have a question concerning a common task, to dynamically plot the results
of some (usually pretty fast) computation.
Approach 1: (Routine `do_it_point_by_point` below)
 just call `plot` successively.
 Here the update frequency gets slower and
 slower the more points are added.
Approach 2: (Routine `do_it_point_by_point`)
 Here one obtains a speed improvement, however the code is
 more complicated (in particular for beginners!). 
To get some speed improvements I figured out that it is better to open just
one plot and then append new data to this one. For large numbers of points
to draw this makes the plot faster. 
Then I wondered 'Why is this so?' and figured out that the plot()-command
(in interactive mode) plots the previous points all over again with each new
point.
Therefore using setp(line, data=('old data + new point')) made everything
faster because now was only one object to handle (which of course is getting
complexer and complexer). Up to this point it is exactly the same as
described in 'anim.py'.
My question is now: Is there a way just to add points to a plot? Because
even in the append-method MPL draws everything again with each draw(). Only
this time MPL has to plot one thing - a circular arc instead of many many
points and is therefore faster.
Remarks:
 - Of course this is only reasonable if autoscale_on=False.
 - in this situation the z-ordering could not be obeyed
 (which would be perfectly ok for this particular usage)
 - No previous points have to be replotted (this is what I would want)
To play around with this idea I tried to use a modified plot routine,
which should just plot the newly added points/lines/...:
#------------------------------------------------------------------
def fastplot(*args, **kwargs):
 b = ishold()
 h = popd(kwargs, 'hold', None)
 if h is not None:
 hold(h)
 try:
 ret = gca().plot(*args, **kwargs)
 renderer = gca().get_renderer_cache()
 gc = renderer.new_gc() # new graphics context
 for line in ret:
 renderer.draw_line(gc, args[0][1], 
 args[0][1],args[1][0], args[1][1])
 except:
 hold(b)
 raise
 hold(b)
 return ret
#------------------------------------------------------------------
However, this (mainly a copy of plot()) does not work (nothing appears on
the screen).
So what do you think:
Is there any possibilty to turn the 'draw everything again
with each plot()-command' off?
My suggestion is that propably the usage of the Renderer (like above)
directly (as described in user's manual) could help. But I'm not really able
to understand what MPL is doing there. 
Is it possible to use the commands described there with existing axis to get
output on the screen? I.e. using something like
 ax = gca()
 renderer = ax.get_renderer_cache()
if some other thing has already been plotted? I tried to go on with the code
from 
the user's manual:
 gc = o.new_gc()
 rec = o.draw_rectangle(gc,face,100,100,200,200)
You can see the rectangle, if interactive-mode is off. This is a drawback
because the issue mentioned at the beginning needs ion(). 
If something like this would be possible it would make things to new
students learning python and mpl much easier.
Thanks for your
help,
Martin
#---------------------------------------------------------------------------------
from pylab import *
import time # for profiling
def do_it_point_by_point(x1,y1):
 print " plot every point seperately ..."
 n = len(x1)
 axis([-1,1,-1,1])
 axis('scaled')
 for i in xrange(n): # plot all data step by step
 plot( [x1[i] ],[y1[i] ],'bo')
def do_it_by_append(x1,y1):
 print " append data to existing plot ..."
 n = len(x1)
 points = plot(x1[0]*ones(2),y1[0]*ones(2),'ro')# draw the first point
 axis([-1,1,-1,1])
 axis('scaled')
 if n>1:
 x_help = list()
 x_help.append(x1[0])
 y_help = list()
 y_help.append(y1[0])
 for i in xrange(1,n-1):
 x_help.append(x1[i])
 y_help.append(y1[i]) # append the rest and ...
 setp(points,data=(array(x_help),array(y_help))) # update data
n=80 # setting n=300 makes the
phi=2.0*pi*arange(n)/n # difference quite
obvious
x=cos(phi)
y=sin(phi)
ion()
print ""
figure(1)
subplot(111, autoscale_on=False)
tstart = time.time()
do_it_point_by_point(x,y)
tend = time.time()
t_old = tend - tstart
close(1)
figure(1)
tstart = time.time()
do_it_by_append(x,y)
tend = time.time()
t_new = tend - tstart
close(1)
ioff()
print ""
print " It took %6.2f s the point-by-point way,"%(t_old)
print " %6.2f s the append way."%(t_new)
-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++
From: Jeff W. <js...@fa...> - 2005年09月09日 13:01:25
Nicolas Girard wrote:
>Hi all,
>I'm still trying to analyse my data using the contour directive. When adding 
>fmt='1.3f' to the arguments, here's what happens:
> 
>
Nicolas: I believe that should be fmt='%1.3f'.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449
325 Broadway Web : http://www.cdc.noaa.gov/~jsw
Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124
From: Arnd B. <arn...@we...> - 2005年09月09日 12:43:23
On Thu, 8 Sep 2005, Mark Bakker wrote:
> The axis('scaled') was a first quick-and-dirty implementation of getting the
> scale of a figure the same along both axes. When it was implemented in the
> previous version, John Hunter commented (correctly) that it didn't work for
> subplots. That is what triggered the clean implementation of axis('equal').
> I think axis('equal') works correctly. Except for the known problem that the
> back button on the toolbar doesn't restore the previous position. I will try
> to fix this in the next week or so.
> I left the axis('scaled') option in, mostly as a novelty, and because I like
> it. But it is only useful if you don't have subplots. Maybe we should just
> get rid of it, as it is not really needed anymore. I have no idea what
> 'scaled' and 'equal' do together.
>
> Regarding the autoscale_on attribute. I don't know what that was designed to
> do. Can anybody explain?
Let me give a try:
There are situations, where the data cover a large range and
one is interested only in a subregion.
Then one can use `axis` to specify the region and
set autoscale_on=False, so that subsequent plots don't change
the limits of the plot
(This is for example to gnuplot's
 set xrange [0.0:10.0]
 set yrange [0.0:10.0]
Gnuplot is more flexible here, as it allows to have autoscaling
on/off on either axis or either limits (uups, another hidden
feature request):
 set xrange [0.0:]
 set yrange [:]
)
> To summarize:
> 1. I will add the position to the history so that the backbutton works.
> 2. Let's remove the axis('scaled') option
Please don't!!! That seems to be the only option which leads
to the behaviour I need.
I am still confused about all the different options
and differing results, in particular when order is changed.
But if matplotlib wants to be compatable with
the behaviour of matplot wrt. `axis("equal")`, I will
stop complaining and just use `axis("scaled")`.... ;-)
Best,
Arnd
From: Nicolas G. <nic...@ne...> - 2005年09月09日 10:49:50
Hi all,
I'm still trying to analyse my data using the contour directive. When adding 
fmt='1.3f' to the arguments, here's what happens:
In [25]:contour(r[0:zmax],z[0:zmax],rho[0:zmax],30,fmt = '1.3f')
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent 
call last)
/home/ngirard/.python/<console>
/usr/lib/python2.4/site-packages/matplotlib/pylab.py in contour(*args, 
**kwargs)
 1784 hold(h)
 1785 try:
-> 1786 ret = gca().contour(*args, **kwargs)
 1787 draw_if_interactive()
 1788 except:
/usr/lib/python2.4/site-packages/matplotlib/axes.py in contour(self, *args, 
**kwargs)
 1251
 1252 def contour(self, *args, **kwargs):
-> 1253 return self._contourHelper.contour(*args, **kwargs)
 1254 contour.__doc__ = ContourSupport.contour.__doc__
 1255
/usr/lib/python2.4/site-packages/matplotlib/contour.py in contour(self, *args, 
**kwargs)
 685 col.set_linestyle((0, (6.,6.)),)
 686 #print "setting dashed"
--> 687 col.set_label(fmt%level)
 688 self.ax.add_collection(col)
 689 collections.append(col)
TypeError: not all arguments converted during string formatting
Any hint ?
Thanks in advance,
cheers,
Nicolas
From: Ken M. <mc...@ii...> - 2005年09月09日 06:09:36
John,
I just submitted a (lightly tested) patch to sourceforge which tries to 
detect that wxPython.h is missing. This situation is handled the same 
way a missing `wx-config' is, in that the build is only killed when 
BUILD_WXAGG is True (as opposed to just emitting a message when it's 
"auto").
Ken
From: Robert K. <rk...@uc...> - 2005年09月09日 05:24:58
Samuel M.Smith wrote:
> With usetex = true, a serif font is used. How to I get matplotlib to 
> use a sans serif font?
> I assume I need to change the font.latex.package but I don't know what
> my choices are.
I don't think so. LaTeX font packages specify one each of serif,
sans-serif, and typewriter faces[1]. The problem is that matplotlib's
generated LaTeX doesn't seem to honor the font.family selection.
You can add something like this at the top of TexManager.get_tex_command():
fontcmd = {'sans-serif': r'{\sffamily %s}',
 'monospace': r'{\ttfamily %s}'}.get(rcParams['font.family'],
 r'{\rmfamily %s}')
tex = fontcmd % tex
[1] But to find which font packages you have installed, go to
/usr/local/share/texmf/tex/latex/ (replace /usr/local with whatever the
prefix is for your TeX installation; also "texmf" may be something
similar like "texmf-dist" in DarwinPorts). Then
 $ ls */*.fd
I think all of those directories that have .fd files in them are font
packages. The package name will be the same as the directory name, I
believe.
-- 
Robert Kern
rk...@uc...
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
 -- Richard Harter
From: Darren D. <dd...@co...> - 2005年09月09日 04:41:28
On Thursday 08 September 2005 11:58 pm, Samuel M.Smith wrote:
> > Yes. If you have LaTeX installed, and set
> >
> > rc('text', usetex=True)
> >
> > then saving to EPS and converting to PDF through any of the various
> > means works fine.
>
> I installed the latest version of TexShop and then tried it.
> It worked. Thanks!
>
> However when I set usetex=True in my matplotlibrc file it does not
> use tex. I have to manually call
> rc('text',usetex=True) inside python, do you know why it does not
> work from the rc file?
The only reason I can think of is that your rc file is stored where mpl can't 
find it, or, you have another rc file somewhere that is being read before the 
one you are editing. 
> With usetex = true, a serif font is used. How to I get matplotlib to
> use a sans serif font?
> I assume I need to change the font.latex.package but I don't know
> what my choices are.
I'm afraid I'm going to have to defer you to the web for available font 
packages. Maybe ask a tex newsgroup... 
Darren
From: Samuel M. S. <sm...@sa...> - 2005年09月09日 03:58:13
> Yes. If you have LaTeX installed, and set
>
> rc('text', usetex=True)
>
> then saving to EPS and converting to PDF through any of the various
> means works fine.
>
>
>
I installed the latest version of TexShop and then tried it.
It worked. Thanks!
However when I set usetex=True in my matplotlibrc file it does not 
use tex. I have to manually call
rc('text',usetex=True) inside python, do you know why it does not 
work from the rc file?
Do I need to delete my font cache? or is something else overriding it 
in the rc file.
With usetex = true, a serif font is used. How to I get matplotlib to 
use a sans serif font?
I assume I need to change the font.latex.package but I don't know 
what my choices are.
this is my rc file section
ont.family : sans-serif
font.style : normal
font.variant : normal
font.weight : medium
font.stretch : normal
font.size : medium
font.serif : New Century Schoolbook, Century Schoolbook L, 
Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 
L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, 
Bitstream Vera Sans, Arial, Helvetica, sans-serif
font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, 
cursive
font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, 
Western, fantasy
font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus 
Mono L, Courier New, Courier, Fixed, Terminal, monospace
font.latex.package : type1cm # This must be an available LaTeX font
#package, like 'times' or 'pslatex' ; only applies if text.usetex is set
From: Christopher H. <chr...@gm...> - 2005年09月09日 01:34:56
Hi,
I recently made an entry at the matplotlib cookbook wiki:
http://www.scipy.org/wikis/topical_software/InteractivePlotting
"""
I find it often quite useful to be able to identify points within a
plot simply by clicking. This recipe provides a fairly simple functor
 that can be connected to any plot. I've used it with both scatter and
standard plots.
"""
I thought I'd post a note here soliciting for comments and suggestions
on how I might do this better and faster. Specifically when the
number of points grows to tens of thousands things begin to crawl. I
was wondering how I can refresh only the text markers rather than the
whole plot? Also, is there a better way to identify the point closet
to where a user clicked? axis.pick doesn't quite do the right thing
because it returns whole collections - right?
Thanks, Chris
From: Eric F. <ef...@ha...> - 2005年09月08日 22:41:23
> 
> On 2005年9月07日, Eric Firing apparently wrote: 
> 
>>> So, the big question is: is it OK, or at least potentially 
>>> OK, to change the pylab API for contour and contourf so 
>>> that they return a single object instead of a tuple? 
> 
> 
> This breaks the matlab analogy.
> I do not care about that myself,
> but people coming from matlab might.
> Maybe the right way to go is to provide an extended 
> contourgroup object 
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/contourgroupproperties.html
> and treat contour and contourf as convenience functions that 
> continue to work as they do.
> 
> fwiw,
> Alan Isaac
Alan,
Actually, it shouldn't hurt people coming from matlab, for two reasons:
1) the present mpl contour and contourf don't return the same things 
that the matlab versions do, anyway;
2) Mathworks has already broken their users' matlab code by changing the 
contour/contourf return values between version 6 and version 7.
The contourgroup is new in version 7. What I have in mind is similar to 
it--although until your message, I had completely forgotten that this is 
the thing that broke all my matlab contouring in version 7. So, the 
proposed change will make mpl contour less like matlab version 6 contour 
and more like version 7; but this is coincidental, not deliberate.
Eric
From: Nicolas G. <nic...@ne...> - 2005年09月08日 22:12:08
On Thursday 08 September 2005 23:55, Jeff Whitaker wrote:
> Nicolas: Sounds like you need to set numerix='numarray'. Try this at
> the beginning of your script:
>
> from matplotlib import rcParams
> rcParams['numerix']= 'numarray'
>
> -Jeff
Jeff : a huge thanks for your damn fast answer ! I was so desperate that I had 
fired up IDL, which I hadn't done for months ! I'm so glad to be able to 
stick with matplotlib !
cheers,
Nicolas
From: Helge A. <he...@gm...> - 2005年09月08日 22:08:58
On 9/8/05, Mark Bakker <ma...@gm...> wrote:
> I left the axis('scaled') option in, mostly as a novelty, and because I
> like it. But it is only useful if you don't have subplots. Maybe we shoul=
d
> just get rid of it, as it is not really needed anymore. I have no idea wh=
at
> 'scaled' and 'equal' do together.=20
please keep it - as it works now axis('scaled') is similar to the
matlab 'axis image' command, which is very useful. as explained in
matlab:
 AXIS EQUAL sets the aspect ratio so that equal tick mark
 increments on the x-,y- and z-axis are equal in size. This
 makes SPHERE(25) look like a sphere, instead of an ellipsoid.
 AXIS IMAGE is the same as AXIS EQUAL except that the plot
 box fits tightly around the data.
axis image is what you want if you like the grid axes to fit tightly
around an image. when the figure window is resized you want the aspect
ratio and the axis ranges preserved. when zooming in/out you want the
aspect ratio preserved.
Helge
From: Jeff W. <js...@fa...> - 2005年09月08日 21:56:00
Nicolas Girard wrote:
>Hi all,
>I need to use contour with data for x,y and z coordinates. My data is 
>contained in 3 numarray arrays called xi,z and rho.
>
>I can call contour with either of these 3 arrays without any problem. But when 
>it comes to pass the 3 arrays, here's the error I get:
>
>In [19]:contour(xi,z,rho)
>---------------------------------------------------------------------------
>exceptions.TypeError Traceback (most recent 
>call last)
>
>/home/ngirard/.python/<console>
>
>/usr/lib/python2.4/site-packages/matplotlib/pylab.py in contour(*args, 
>**kwargs)
> 1784 hold(h)
> 1785 try:
>-> 1786 ret = gca().contour(*args, **kwargs)
> 1787 draw_if_interactive()
> 1788 except:
>
>/usr/lib/python2.4/site-packages/matplotlib/axes.py in contour(self, *args, 
>**kwargs)
> 1251
> 1252 def contour(self, *args, **kwargs):
>-> 1253 return self._contourHelper.contour(*args, **kwargs)
> 1254 contour.__doc__ = ContourSupport.contour.__doc__
> 1255
>
>/usr/lib/python2.4/site-packages/matplotlib/contour.py in contour(self, *args, 
>**kwargs)
> 675 tlinewidths = [(w,) for w in linewidths]
> 676
>--> 677 C = _contour.Cntr(x, y, z.filled(), z.mask())
> 678 for level, color, width in zip(lev, tcolors, tlinewidths):
> 679 nlist = C.trace(level, points = 1)
>
>TypeError: Arguments x, y, z, (optional) mask must be arrays.
>
>
>
>
>I really don't understand where the problem is. All arrays are of the same 
>nature:
>
>In [20]:for a in [xi,z,rho]:
> .20.: shape(a)
> .20.: type(a)
> .20.:
>Out[20]:(1025, 1024)
>Out[20]:<class 'numarray.numarraycore.NumArray'>
>Out[20]:(1025, 1024)
>Out[20]:<class 'numarray.numarraycore.NumArray'>
>Out[20]:(1025, 1024)
>Out[20]:<class 'numarray.numarraycore.NumArray'>
>
>
>
>Do you have any idea to help me solve this problem ?
>
>Thanks in advance,
>cheers,
>Nicolas
>
>
>
> 
>
Nicolas: Sounds like you need to set numerix='numarray'. Try this at 
the beginning of your script:
from matplotlib import rcParams
rcParams['numerix']= 'numarray'
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Mark B. <ma...@gm...> - 2005年09月08日 21:19:54
The axis('scaled') was a first quick-and-dirty implementation of getting th=
e=20
scale of a figure the same along both axes. When it was implemented in the=
=20
previous version, John Hunter commented (correctly) that it didn't work for=
=20
subplots. That is what triggered the clean implementation of axis('equal').=
=20
I think axis('equal') works correctly. Except for the known problem that th=
e=20
back button on the toolbar doesn't restore the previous position. I will tr=
y=20
to fix this in the next week or so.
I left the axis('scaled') option in, mostly as a novelty, and because I lik=
e=20
it. But it is only useful if you don't have subplots. Maybe we should just=
=20
get rid of it, as it is not really needed anymore. I have no idea what=20
'scaled' and 'equal' do together.=20
Regarding the autoscale_on attribute. I don't know what that was designed t=
o=20
do. Can anybody explain?
To summarize:
1. I will add the position to the history so that the backbutton works.
2. Let's remove the axis('scaled') option
3. I don't know how to keep axes scaled when the window size is changed.=20
Anybody know how to catch such an event?
Mark
On 9/8/05, Martin Richter <law...@gm...> wrote:
>=20
> Hello Mark,
> Hello everyone,
>=20
> I wrote myself a little program which juggled five commands in all=20
> possible
> orders saving each plottingresult in a png. What I could see was that=20
> (with
> autoscale_on=3DFalse) the commands
>=20
> imshow(something),
> plot(something)
> axis('scaled')
> axis('equal')
> axis([-2,2,-3,3]))
>=20
> had to obey two rules. Then and only then the plot looked like I wanted
> (i.e. it had the correct limits given by axis([...]) and a circle looked
> like a circle).
> (i) plot() has to be before axis([-2,2,-3,3])
> (ii) imshow() has to be before axis([-2,2,-3,3])
>=20
> I think (i) everyone knows from everyday experience with MPL. Then (ii)
> doesn't suprise too much.
>=20
> Remark 1)
> I put axis('equal') AND axis('scaled') in, just to check out
> if everything works fine. It seems to me that axis('scaled') overrules
> axis('equal').
> In other words: I suppose axis('equal') doesn' set fixLimits=3DFalse.
> I - preferring axis('scaled') - doesn't find this to bad. But nevertheles=
s
> it could be confusing to the user who prefers the other option ... on the
> other hand: Propably no-one uses axis('equal') AND axis('scaled') in one
> program (except me doing a 120 permutations ;-)
>=20
> Remark 2)
> Still: I can't become a really friend of this. If autoscale_on=3DTrue I=
=20
> would
> understand (i) and (ii). But it is False. When plotting doesn't autoscale
> why are the limits changed? In other words: Why (i) and (ii)? You could
> propably say: We already talked about the difference in
> axis('equal')
> axis([-2,2,-3,3])
> and
> axis([-2,2,-3,3])
> axis('equal').
> But this is not true for axis('scaled'). Here the order doesn't play a=20
> role
> (At least I saw this in a seperate example and I also couldn't figure out
> that the order played a role for 'scaled' in my permutations - notice the
> "Then and only then" before (i) and (ii)!)
>=20
> That's as far as I came right now.
> Bye,
> Martin
>=20
> PS: I don't know if this permutation-doing program is of any use to you.
> That's why I haven't attached it. If you would like to have it - let me=
=20
> know
> ... but I wouldn't exhibit it in the Louvre if you know what I mean ;-)
>=20
> --
> Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
> Satte Provisionen f=FCr GMX Partner: http://www.gmx.net/de/go/partner
>
From: Travis B. <td...@fa...> - 2005年09月08日 20:29:28
Anybody know how to update the Matplotlib distribution contained within
the Enthought Python distribution?
There seems to be no uninstaller for any of the packages and I'd like to
update to the latest mpl.
thanks,
Travis
-- 
 Travis Brady
 td...@fa...
-- 
http://www.fastmail.fm - mmm... Fastmail...
From: Nicolas G. <nic...@ne...> - 2005年09月08日 20:29:20
Hi all,
I need to use contour with data for x,y and z coordinates. My data is 
contained in 3 numarray arrays called xi,z and rho.
I can call contour with either of these 3 arrays without any problem. But when 
it comes to pass the 3 arrays, here's the error I get:
In [19]:contour(xi,z,rho)
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent 
call last)
/home/ngirard/.python/<console>
/usr/lib/python2.4/site-packages/matplotlib/pylab.py in contour(*args, 
**kwargs)
 1784 hold(h)
 1785 try:
-> 1786 ret = gca().contour(*args, **kwargs)
 1787 draw_if_interactive()
 1788 except:
/usr/lib/python2.4/site-packages/matplotlib/axes.py in contour(self, *args, 
**kwargs)
 1251
 1252 def contour(self, *args, **kwargs):
-> 1253 return self._contourHelper.contour(*args, **kwargs)
 1254 contour.__doc__ = ContourSupport.contour.__doc__
 1255
/usr/lib/python2.4/site-packages/matplotlib/contour.py in contour(self, *args, 
**kwargs)
 675 tlinewidths = [(w,) for w in linewidths]
 676
--> 677 C = _contour.Cntr(x, y, z.filled(), z.mask())
 678 for level, color, width in zip(lev, tcolors, tlinewidths):
 679 nlist = C.trace(level, points = 1)
TypeError: Arguments x, y, z, (optional) mask must be arrays.
I really don't understand where the problem is. All arrays are of the same 
nature:
In [20]:for a in [xi,z,rho]:
 .20.: shape(a)
 .20.: type(a)
 .20.:
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Do you have any idea to help me solve this problem ?
Thanks in advance,
cheers,
Nicolas
From: Sascha <sas...@gm...> - 2005年09月08日 20:14:30
Message> For importing External Method in Zope, what is the module to=20
import?
Create a file (e.g. mpl.py) in INSTANCEHOME\Extensions.
------ mpl.py: ---------------------
from pylab import *
from os import *
from StringIO import StringIO
from PIL import Image as PILImage
from matplotlib.backends.backend_agg import FigureCanvasAgg
def chart(self):
 clf()
 dpi=3D72
 width=3D400
 height=3D300
 fig=3Dfigure(dpi, figsize=3D(width/dpi, height/dpi))
 #ax=3Dsubplot(111)
 x=3Darange(0, 2*pi+0.1, 0.1)
 sine=3Dplot(x, sin(x))
 legend(sine, "y=3Dsin x", "upper right")
 xlabel('x')
 ylabel('y=3Dsin x')
 grid(True)
 canvas =3D FigureCanvasAgg(fig)
 canvas.draw()
 size =3D canvas.get_width_height()
 buf=3Dcanvas.tostring_rgb()
 im=3DPILImage.fromstring('RGB', size, buf, 'raw', 'RGB', 0, 1)
 imgdata=3DStringIO()
 im.save(imgdata, 'PNG')
 self.REQUEST.RESPONSE.setHeader('Pragma', 'no-cache')
 self.REQUEST.RESPONSE.setHeader('Content-Type', 'image/png')
 return imgdata.getvalue()
-------------------------------------------
Then create an external method in ZMI (e.g. Id -> mplchart, module name =
->=20
mpl, function name -> chart).
> matplotlib or pylab Do you also have to import numeric python first?
If you import pylab, then there is no need to import Numeric.
> I need a real world example not a 'foo.py' module.
See above.
Regards,
Sascha=20
From: Helge A. <he...@gm...> - 2005年09月08日 17:39:00
On 9/8/05, Martin Richter <law...@gm...> wrote:
> Remark 2)
> Still: I can't become a really friend of this. If autoscale_on=3DTrue I w=
ould
> understand (i) and (ii). But it is False. When plotting doesn't autoscale
> why are the limits changed? In other words: Why (i) and (ii)? You could
> propably say: We already talked about the difference in
Hello,
I agree that autoscaling combined with e.g. axis('scaled') is really broken=
...=20
my worst annoyance is how the figure size is changed when I do
axis('scaled') and use the zoom to rect mode, e.g.
from pylab import *
im=3D3 ; jm=3D4
[y,x] =3D meshgrid(arange(0.5,jm+0.5), arange(0.5,im+0.5))
h =3D sqrt(x**2 + y**2)
pcolor(x,y,h)
axis([0,im,0,jm])
axis('scaled')
hsv()=20
show()
=20
then zoom to rect and pick a very "wide" rectangle - figure changes
size, now zooming to a tall rectangle will make the figure size thin
and tall instead. clicking home restores the axis limits, but the
weird figure size remains... (I use cvs matplotlib)
humble suggestion for developers: using the right button to zoom out
to a rectangle is not intuitive - I would much prefer if a single
right click in the figure in this mode just took me back to the
previous axis limits. and if axis('scaled') is on, it should preserve
the figure aspect ratio no matter what happen - window resize, zooming
in/out, whatever...
otherwise, matplotlib is really improving! good job. the only features
I miss are a pcolor and quiver capable of doing 500x500 data as fast
as pygist :)
for those hacking on the colorbar: the scipy xplt colorbar is nice. it
may be possible to use some of the scaling algs. from that one. (see
http://www.scipy.org/cvs/viewcvs/map?rmurl=3Dhttp%3A//scipy.net/cgi-bin/vie=
wcvsx.cgi/scipy1/xplt/colorbar.py%3Frev%3D1.7%26content-type%3Dtext/vnd.vie=
wcvs-markup)
sincerely,
Helge
From: Dougall, D. <dou...@cb...> - 2005年09月08日 16:39:24
I am a new Zope user and am trying to use matplotlib in a Zope application
and need some guidance on how to do so. 
 
From a previous post in February 2005 (2-17-05), someone had a similar
problem. From the archives, I'm not quite sure it was solved.
This is the only related answer I found.
 
From: Yves Moisan <ymoisan@gr...>
 <http://images.sourceforge.net/images/msg.gif> Matplotlib in a Zope and
postgreSQL context 
2005年04月29日 09:16	
 
 1) Is there a way people know of integrating Matplotlib into Zope ? I had
to
 fight with the registry (yes, a windows box for now) to get matplotlib to
 install on the right Python (Zope"s, not the system Python) but more
importantly
 I am using an external method to gain access to matplotlib via Zope. It
works,
 but it"s clumsy and I suspect loading up pylab could be quicker if I could
use
 Scripts (Python) objects in Zope.
For importing External Method in Zope, what is the module to import?
matplotlib or pylab Do you also have to import numeric python first? 
What would the functions be in the External Method import? (example: plot,
arange, xlabel, etc.???)
The other method listed was to install in the right Python (Zope's) by
fighting with the windows registry. How is this actually done from someone
with less computer programming knowledge? Is matplotlib installed in the
python directory of the main Zope directory or the Zope Instance directory?
I copied the matplotlib directory from my python directory (not Zope) to
both the Zope directory (...\lib\python\) and Zope Instance directory
(...\Extensions\) in the hope one would work.
Error Type: ImportError
Error Value: import of "pylab" is unauthorized
How do I get security clearance for matplotlib? The information from Zope
isn't as detailed as I would need. I need a real world example not a
'foo.py' module.
Thank you.
Dave
From: Ken M. <mc...@ii...> - 2005年09月08日 15:11:32
On Sep 8, 2005, at 8:46 AM, John Hunter wrote:
> Kevin, Do you think it would be possible to make the BUILD_WXAGG logic
> a little smarter so that it doesn't kill the build process? Or
> perhaps set BUILD_WXAGG to False by default.
I will review buildext.py and see if I can add a check for the presence 
of `wxPython.h'. For now, you should probably set BUILD_WXAGG to False 
by default.
Maybe I should get this Kevin guy to help ;-)
> I'm afraid this one will bite a lot of people who have wxpython 
> installed
> but not the devel headers (as noted in previous discussions, the 
> debian devel
> packages appear broken with respect to wxPython.h).
I'm working with Ron Lee to get that fixed. It looks like it may be an 
upstream issue, in that the wxPython distutils script doesn't even try 
to install the headers. It probably won't be a hard fix, once I've 
made sure I understand the problem.
Ken
3 messages has been excluded from this view by a project administrator.

Showing results of 352

<< < 1 .. 7 8 9 10 11 .. 15 > >> (Page 9 of 15)
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 によって変換されたページ (->オリジナル) /