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






Showing results of 339

1 2 3 .. 14 > >> (Page 1 of 14)
From: Eric F. <ef...@ha...> - 2006年12月31日 20:53:18
Jeff Whitaker wrote:
> # reverse sign of data, so contours won't be dashed.
> cs = m.contour(x, y, -topoin, [1000, 2000], colors='r')
You can also use
rcParams['contour.negative_linestyle'] = 'solid'
to tell contour not to make monochrome negative contours dashed.
Eric
From: Jeff W. <js...@fa...> - 2006年12月31日 20:41:36
Evan Mason wrote:
> In the mpl basemap 'test.py' script, I want to add some contours to 
> the mercator projection map (test #3). Just below line 83 (ie, below 
> the 'im = imshow..' command I added the line:
>
> m.contour(topodat,[-1000, -2000])
>
> This returns:
>
> /home/evan/downloads/basemap-0.9.4/examples/test.py
> 82 # plot image over map.
> 83 im = m.imshow(topodat,cm.jet)
> ---> 84 m.contour(topodat,[-1000, -2000])
> 85 m.drawcoastlines ()
> 86 m.drawcountries()
>
> TypeError: contour() takes at least 4 arguments (3 given)
> WARNING: Failure executing file: <test.py>
>
> I understand the error to mean that I haven't supplied x and y values; 
> however at this point, if I close all the open figures and enter the 
> line 'contour(topodat,[-1000, -2000])' at the ipython command, it 
> gives me the plot I want.
>
> I've then tried to use meshgrid to make x and y values (see code 
> below); this is error free but the contours don't appear. Again, 
> using contour in the command line I get the plot I want. Is it not 
> possible to plot on top of imshow?
>
> Any help appreciated.
>
>
> Thanks, Evan
>
>
>
>
> from matplotlib.toolkits.basemap import Basemap, shiftgrid
> from scipy import interpolate as Pinterp
> from pylab import *
> import matplotlib.colors as colors
>
> def doSpline(yVec, newLatRange):
> latRange = range(len(yVec))
> newLatRange = linspace(latRange[0], latRange[-1], newLatRange)
> tck = Pinterp.splrep(latRange, yVec)
> yVec = Pinterp.splev(newLatRange, tck)
> return yVec
>
> topodatin = load('etopo20data.gz')
> lonsin = load('etopo20lons.gz')
> latsin = load('etopo20lats.gz')
> # shift data so lons go from -180 to 180 instead of 20 to 380.
> topoin,lons = shiftgrid(180.,topodatin,lonsin,start=False)
> lats = latsin
> # transform to nx x ny regularly spaced native projection grid
> nx = len(lons)
> ny = int(80.*len(lats)/90.)
> lats_ny = doSpline(lats, ny)
>
> lons_mesh, lats_mesh = meshgrid(lons, lats_ny)
>
> # setup mercator map projection (-80 to +80).
> m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\
> resolution='c',area_thresh=10000.,projection='merc',\
> lon_0=0.5*(lons[0]+lons[-1]),lat_ts=20.)
>
> topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
>
> # setup figure with same aspect ratio as map.
> fig=figure()
> fig.add_axes([0.1,0.1,0.75,0.75])
> # plot image over map.
> im = m.imshow(topodat,cm.jet)
> # PLOT CONTOURS
> m.contour(lons_mesh, lats_mesh, topodat,[-1000, -2000, -3000])
> show()
>
Evan: This works for me:
from matplotlib.toolkits.basemap import Basemap, shiftgrid
from pylab import *
topodatin = load('etopo20data.gz')
lonsin = load('etopo20lons.gz')
latsin = load('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topodatin,lonsin,start=False)
lats = latsin
# setup mercator map projection (-80 to +80).
m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\
 resolution='c',area_thresh=10000.,projection='merc',\
 lon_0=0.5*(lons[0]+lons[-1]),lat_ts=20.)
# transform to nx x ny regularly spaced native projection grid
nx = len(lons); ny = len(lats)
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# setup figure with same aspect ratio as map.
# plot image over map.
im = m.imshow(topodat,cm.jet)
# PLOT CONTOURS
longrid,latgrid = meshgrid(lons,lats)
x, y = m(longrid,latgrid)
# reverse sign of data, so contours won't be dashed.
cs = m.contour(x, y, -topoin, [1000, 2000], colors='r')
m.drawcoastlines()
show()
Unlike the pylab contour command, the basemap contour method requires 
you to supply the X and Y values.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Evan M. <eva...@gm...> - 2006年12月31日 20:09:29
In the mpl basemap 'test.py' script, I want to add some contours to the
mercator projection map (test #3). Just below line 83 (ie, below the 'im =
imshow..' command I added the line:
m.contour(topodat,[-1000, -2000])
This returns:
/home/evan/downloads/basemap-0.9.4/examples/test.py
 82 # plot image over map.
 83 im = m.imshow(topodat,cm.jet)
---> 84 m.contour(topodat,[-1000, -2000])
 85 m.drawcoastlines()
 86 m.drawcountries()
TypeError: contour() takes at least 4 arguments (3 given)
WARNING: Failure executing file: <test.py>
I understand the error to mean that I haven't supplied x and y values;
however at this point, if I close all the open figures and enter the line
'contour(topodat,[-1000, -2000])' at the ipython command, it gives me the
plot I want.
I've then tried to use meshgrid to make x and y values (see code below);
this is error free but the contours don't appear. Again, using contour in
the command line I get the plot I want. Is it not possible to plot on top
of imshow?
Any help appreciated.
Thanks, Evan
from matplotlib.toolkits.basemap import Basemap, shiftgrid
from scipy import interpolate as Pinterp
from pylab import *
import matplotlib.colors as colors
def doSpline(yVec, newLatRange):
 latRange = range(len(yVec))
 newLatRange = linspace(latRange[0], latRange[-1], newLatRange)
 tck = Pinterp.splrep(latRange, yVec)
 yVec = Pinterp.splev(newLatRange, tck)
 return yVec
topodatin = load('etopo20data.gz')
lonsin = load('etopo20lons.gz')
latsin = load('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topodatin,lonsin,start=False)
lats = latsin
# transform to nx x ny regularly spaced native projection grid
nx = len(lons)
ny = int(80.*len(lats)/90.)
lats_ny = doSpline(lats, ny)
lons_mesh, lats_mesh = meshgrid(lons, lats_ny)
# setup mercator map projection (-80 to +80).
m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\
 resolution='c',area_thresh=10000.,projection='merc',\
 lon_0=0.5*(lons[0]+lons[-1]),lat_ts=20.)
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# setup figure with same aspect ratio as map.
fig=figure()
fig.add_axes([0.1,0.1,0.75,0.75])
# plot image over map.
im = m.imshow(topodat,cm.jet)
# PLOT CONTOURS
m.contour(lons_mesh, lats_mesh, topodat,[-1000, -2000, -3000])
show()
From: Fernando P. <fpe...@gm...> - 2006年12月31日 19:38:47
Hi Belinda,
On 12/29/06, belinda thom <bt...@cs...> wrote:
> Hi,
>
> I'm using matplotlib w/numerix set to numpy (as described in my prior
> post).
>
> What I am wondering is in what situations one would want to:
>
> import pylab
> import numpy
>
> together, because there is matlab-style stuff (e.g. matrices, arrays,
> cumprod, fft, arange etc.) by importing the pylab package alone.
To add to Eric's detailed reply, keep in mind that much of this
duplication is a historical accident. John Hunter developed mpl (and
hence pylab) back in the Dark Days of the Split (aka, when we lived
with Numeric and Numarray, both lacking critical functionality). At
that time he needed various pieces of numerical functionality for his
own work, so the most logical thing to do was to put it in the package
he had control over: matplotlib. In fact, the same thing happened in
three places: if you look at the python landscape for these tools
around 2003/4, you'll find that ipython, scipy and matplotlib ALL had
tools for: interactive work, plotting and numerics. Over time, as
each package has matured, we've all tried to move away from this, so
that hopefully the responsibilities will be:
- ipython -> interactive work
- numpy/scipy -> numerics
- matploblib -> plotting
While little code has been removed yet (to avoid breaking
compatibility for existing users), at least most of what mattered has
been moved to where it makes sense: numpy inherited utilities from
ipython and pylab, ipython has absorbed the interactive support for
matplotlib and I don't develop its plotting tools anymore (they were
for gnuplot), etc.
Following these ideas, in my personal use I normally do:
import numpy as N
import scipy as S
import pylab as P
and I try to use P.plottingStuff(), N.arrayStuff() and
S.scipyOnlyThings(). I think this is an approach that better matches
the real intent of these tools for the long term.
I hope this is useful.
best,
f
From: Allan N. E. <all...@gm...> - 2006年12月31日 06:01:13
when running the embedding_in_wx4.py available in the examples.zip i always
get an error dialog that a wxmsw26uh_vc.dll is missing. Pressing ok button
of the error dialog makes the program run as usual. When I modified the code
and added the line "from pylab import *" the program does not give the
nagging error dialog. Adding that line is a fix but I want to find out why
the program needs this dll and how can I alter the code so that I will not
use the "from pylab import *".I use wxPython 2.7, Python 2.5 and Matplotlib
0.87.7
From: Eric F. <ef...@ha...> - 2006年12月30日 03:04:09
Sourceforge does seem to be fouled up, but the following is up to date:
http://www.mail-archive.com/mat...@li.../maillist.html#01707
Eric
belinda thom wrote:
> Hi,
> 
> The source forge archive for this mailing list:
> 
> http://sourceforge.net/mailarchive/forum.php? 
> forum_id=33405&max_rows=25&style=ultimate&viewmonth=200612
> 
> has no posts listed as of 12/24/06. I've posted several things today 
> and would like to be able to view their progress. Has this archive 
> moved?
> 
> Thanks,
> 
> --b
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Eric F. <ef...@ha...> - 2006年12月30日 02:54:14
Belinda,
I will give a short answer, and maybe someone else will be able to 
provide a more complete answer or a reference to one.
belinda thom wrote:
> Hi,
> 
> I'm using matplotlib w/numerix set to numpy (as described in my prior 
> post).
> 
> What I am wondering is in what situations one would want to:
> 
> import pylab
> import numpy
One reason for doing this would be make it clear where your numeric 
components are really coming from, and to take full advantage of numpy.
An idiom that I often use is
import pylab as P
import numpy as N
and then anything that ultimately comes from numpy anyway, like arange, 
I invoke as N.arange rather than P.arange. Or you can do it all at the 
top of the script with "from pylab import ..." and "from numpy import ...".
> 
> together, because there is matlab-style stuff (e.g. matrices, arrays, 
> cumprod, fft, arange etc.) by importing the pylab package alone.
> 
Pylab is a convenience package that aggregates plotting and numerical 
functionality in a single namespace while hiding the differences among 
numeric packages. This support of alternative numeric packages has been 
an important part of matplotlib, but its utility will diminish and it 
will be phased out now that numpy is ready to use. An advantage of 
using numpy directly now, rather than via the parts of it that pylab 
imports, is that you will be getting accustomed to the new numpy style 
rather than the compatibility mode.
> On a related note, in trying to get a better idea of how math vs. 
> plot functionality is handled in matplotlib, I looked at mlab.py and 
> pylab.py; it doesn't seem there is a clear separation of these 
> functions, but perhaps I'm missing something?
> 
You are correct. Pylab imports everything from matplotlib.numerix.mlab. 
 Confusingly, there is a matplotlib.mlab and a matplotlib.numerix.mlab 
which uses an mlab from the selected numerical package. The numpy 
version of mlab, in turn, imports lots of stuff from numpy--it is 
another aggregator. It seems that numpy's mlab is trying to give a 
Matlab-like environment without the plotting, and pylab is trying to do 
the same thing but with the plotting included.
The net results of the attempts of numpy and pylab to make things 
convenient by aggregating functionality in a single namespace are (1) it 
really can be convenient--a one-stop shop, and (2) it can be very 
confusing with all the possible places things can get imported from, 
some of them with similar names.
Ipython is enormously helpful in showing where things really come from. 
For example in an "ipython -pylab" session, where "from pylab import *" 
has been done automatically by ipython, we get:
In [1]:arange?
Type: function
Base Class: <type 'function'>
String Form: <function arange at 0xb54f8ca4>
Namespace: Interactive
File: 
/usr/local/lib/python2.4/site-packages/numpy/oldnumeric/functions.py
Definition: arange(start, stop=None, step=1, typecode=None, dtype=None)
Docstring:
 <no docstring>
Note that pylab is pulling in numpy's backwards-compatibility version of 
arange rather than its native version.
Here is another example of different versions of a function with the 
same name, first the pylab version, then the numpy version:
In [3]:linspace?
Type: function
Base Class: <type 'function'>
String Form: <function linspace at 0xb53f59cc>
Namespace: Interactive
File: /usr/local/lib/python2.4/site-packages/matplotlib/mlab.py
Definition: linspace(xmin, xmax, N)
Docstring:
 <no docstring>
In [4]:import numpy
In [5]:numpy.linspace?
Type: function
Base Class: <type 'function'>
String Form: <function linspace at 0xb5570df4>
Namespace: Interactive
File: 
/usr/local/lib/python2.4/site-packages/numpy/lib/function_base.py
Definition: numpy.linspace(start, stop, num=50, endpoint=True, 
retstep=False)
Docstring:
 Return evenly spaced numbers.
 Return num evenly spaced samples from start to stop. If
 endpoint is True, the last sample is stop. If retstep is
 True then return the step value used.
Depending on what you are doing and on the style you prefer, you may 
want to use as much as possible from pylab, or you may want to use only 
a few things from the pylab namespace and then explicitly use the 
matplotlib and numpy namespaces (and object methods) for everything 
else. A bit of this is discussed in the matplotlib 
examples/pythonic_matplotlib.py.
I am inclined to directly invoke numpy instead of going through pylab 
and numerix.
That was longer than I intended for this message... but the complexity 
of A importing things from B and B from A via B.C, etc. is making my 
head spin. I hope that in the process of switching matplotlib to 
numpy-only we will be able to simplify all this.
Eric
From: belinda t. <bt...@cs...> - 2006年12月30日 01:58:15
Hi,
The source forge archive for this mailing list:
 http://sourceforge.net/mailarchive/forum.php? 
forum_id=33405&max_rows=25&style=ultimate&viewmonth=200612
has no posts listed as of 12/24/06. I've posted several things today 
and would like to be able to view their progress. Has this archive 
moved?
Thanks,
--b
From: belinda t. <bt...@cs...> - 2006年12月29日 21:06:19
Hi,
I'm using matplotlib w/numerix set to numpy (as described in my prior 
post).
What I am wondering is in what situations one would want to:
import pylab
import numpy
together, because there is matlab-style stuff (e.g. matrices, arrays, 
cumprod, fft, arange etc.) by importing the pylab package alone.
On a related note, in trying to get a better idea of how math vs. 
plot functionality is handled in matplotlib, I looked at mlab.py and 
pylab.py; it doesn't seem there is a clear separation of these 
functions, but perhaps I'm missing something?
Thanks!
--b
From: Eric F. <ef...@ha...> - 2006年12月29日 19:38:13
Petr Danecek wrote:
> Hello,
> first of all: thanks for the great software!! After the years of
> struggling with gnuplot, i really enjoy making my graphs with
> matplotlib.
> 
> I'd like to ask, if it is possible to create a contour graph using polar
> coordinates? If not, can someone give me some pointers about how to
> implement it? 
John has said that he plans to improve polar coordinate handling in the 
next month or two. If it turns out that changes are also needed in 
contour.py, I will be happy to make them. So, if all goes well, within 
a few months we should have contouring and other things working well 
with polar coordinates. In the meantime, I am glad Jeff has provided a 
workaround.
(I took a stab at making contouring work to a useful degree with present 
polar coordinates--given that pcolor works, it should be possible--but I 
couldn't quite get it. Maybe I will try again later.)
Eric
From: Eric E. <ems...@ob...> - 2006年12月29日 19:35:49
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
sorry for all this. I guess I don't fully understand the bbox thing....<br>
<br>
Anyway it works great except for 2 things:<br>
** now the x,y coordinates in the toolbar are VERY SLOWLY updated... In
fact as the mouse moves, the coordinates do not show up and are only
updated when it is stopped.<br>
** my text does not appear fully (some part is blanked, and changing
the bbox does not seem to do much)<br>
<br>
Eric<br>
<br>
John Hunter wrote:
<blockquote cite="mid...@pe..."
 type="cite">
 <blockquote type="cite">
 <blockquote type="cite">
 <blockquote type="cite">
 <blockquote type="cite">
 <blockquote type="cite">
 <pre wrap="">"Eric" == Eric Emsellem <a class="moz-txt-link-rfc2396E" href="mailto:ems...@ob...">&lt;ems...@ob...&gt;</a> writes:
 </pre>
 </blockquote>
 </blockquote>
 </blockquote>
 </blockquote>
 </blockquote>
 <pre wrap=""><!---->
 Eric&gt; great! but one question though: I need to put the text with
 Eric&gt; figtext and thus use figure coordinates (instead of pixel
 Eric&gt; coord). So how would I replace the :
 Eric&gt; matplotlib.transforms.lbwh_to_bbox
It shouldn't matter which way you create the text instance.
JDH
 </pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
====================================================================
Eric Emsellem <a class="moz-txt-link-abbreviated" href="mailto:ems...@ob...">ems...@ob...</a>
 Centre de Recherche Astrophysique de Lyon
9 av. Charles-Andre tel: +33 (0)4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 (0)4 78 86 83 86
France <a class="moz-txt-link-freetext" href="http://www-obs.univ-lyon1.fr/eric.emsellem">http://www-obs.univ-lyon1.fr/eric.emsellem</a>
====================================================================
</pre>
</body>
</html>
From: Jeff W. <js...@fa...> - 2006年12月29日 19:19:51
Petr Danecek wrote:
> Beautiful! The grid lines must be drawn manually?
>
> On Thu, 2006年12月28日 at 13:32 -0700, Jeff Whitaker wrote:
> 
>> Here's a slightly prettier version of my previous example:
>>
>> from pylab import *
>> deltatheta = 2.*pi/100.
>> theta = arange(0.,2.*pi+0.5*deltatheta,deltatheta)
>> R = arange(0.,pi,deltatheta)
>> r,t = meshgrid(R, theta)
>> Z = sin(r)*sin(3.*t)
>> X = r*cos(t)
>> Y = r*sin(t)
>> ax = subplot(111)
>> cs = ax.contourf(X,Y,Z)
>> # make sure aspect ratio preserved
>> ax.set_aspect('equal')
>> # turn off rectangular frame.
>> ax.set_frame_on(False)
>> # turn off axis ticks.
>> ax.set_xticks([])
>> ax.set_yticks([])
>> # draw a circle around the edge of the plot.
>> rmax = max(R)
>> ax.plot(rmax*cos(theta),rmax*sin(theta),'k')
>> title('Polar contours')
>> show()
>>
>> 
>
> 
Petr: Here's yet another way to do it, using the basemap toolkit. This 
way you get axis grid lines.
from matplotlib.toolkits.basemap import Basemap
import pylab
theta = pylab.linspace(0.,2.*pylab.pi,101)
R = pylab.linspace(0.,pylab.pi,101)
lat,lon = pylab.meshgrid(R, theta)
Z = pylab.sin(lat)*pylab.sin(4*lon) + pylab.exp(-(lat**2/4))
# convert radial coordinate to latitude, with r=0 being north pole
# and r=rmax being equator.
# convert r and theta to degrees.
lat = (180./pylab.pi)*0.5*lat[::-1,:]
lon = (180./pylab.pi)*lon
m = Basemap(boundinglat=0.,lon_0=0.,resolution=None,projection='npaeqd')
X,Y = m(lon,lat)
CS = m.contourf(X,Y,Z,15)
m.drawparallels(pylab.arange(0,90,20),labels=[1,1,1,1])
m.drawmeridians(pylab.arange(0,360,60),labels=[1,1,1,1])
pylab.show()
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: belinda t. <bt...@cs...> - 2006年12月29日 18:54:07
Hi,
I'm unable to use matplotlib when I have the following line in my 
matlabplotrc file: numerix Numeric.
There is no problem when I use: numerix numpy
Here's my setup: Mac G5 w/OS X 10.4.8, using MacPython 2.4, 
numpy.__version__ is 1.0, matplotlib.__version__ 0.87.7 and 
Numeric.__version__ 24.2
I append below the errors I get when trying to use numerix Numeric 
via python and ipython.
Is this a bug?
--b
VIA IPYTHON:
====================
6 % ipython -pylab
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.7.2 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
 Welcome to pylab, a matplotlib-based Python environment.
 For more information, type 'help(pylab)'.
In [1]: plot([1,2,3])
------------------------------------------------------------------------ 
---
exceptions.TypeError Traceback (most 
recent call last)
/Users/bthom/belinda/mills/aicourse/tic-tac-toe/<ipython console>
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/pylab.py in plot(*args, **kwargs)
 2025 hold(h)
 2026 try:
-> 2027 ret = gca().plot(*args, **kwargs)
 2028 draw_if_interactive()
 2029 except:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in plot(self, *args, **kwargs)
 2129 lines = [line for line in lines] # consume the 
generator
 2130
-> 2131 self.autoscale_view(scalex=scalex, scaley=scaley)
 2132 return lines
 2133
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in autoscale_view(self, tight, scalex, 
scaley)
 983 if xl[1] < xl[0]:
 984 XL = XL[::-1]
--> 985 self.set_xlim(XL)
 986 if scaley:
 987 yl = self.get_ylim()
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in set_xlim(self, xmin, xmax, emit)
 1225 xmax += 1e-38
 1226
-> 1227 self.viewLim.intervalx().set_bounds(xmin, xmax)
 1228 if emit: self._send_xlim_event()
 1229 return xmin, xmax
TypeError: only length-1 arrays can be converted to Python scalars.
.pdbrc.py started
.pdbrc.py finished
 > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ 
site-packages/matplotlib/axes.py(1227)set_xlim()
 1226
-> 1227 self.viewLim.intervalx().set_bounds(xmin, xmax)
 1228 if emit: self._send_xlim_event()
VIA PYTHON:
=================
3 % python
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
history mechanism set up
 >>> import pylab
 >>> pylab.plot([1,2,3])
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/matplotlib/pylab.py", line 2027, in plot
 ret = gca().plot(*args, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/matplotlib/axes.py", line 2131, in plot
 self.autoscale_view(scalex=scalex, scaley=scaley)
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/matplotlib/axes.py", line 985, in autoscale_view
 self.set_xlim(XL)
 File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/matplotlib/axes.py", line 1227, in set_xlim
 self.viewLim.intervalx().set_bounds(xmin, xmax)
TypeError: only length-1 arrays can be converted to Python scalars.
From: John H. <jdh...@ac...> - 2006年12月29日 18:53:55
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
 Eric> great! but one question though: I need to put the text with
 Eric> figtext and thus use figure coordinates (instead of pixel
 Eric> coord). So how would I replace the :
 Eric> matplotlib.transforms.lbwh_to_bbox
It shouldn't matter which way you create the text instance.
JDH
From: Eric E. <ems...@ob...> - 2006年12月29日 18:50:35
great! but one question though: I need to put the text with figtext and
thus use figure coordinates (instead of pixel coord).
So how would I replace the :
matplotlib.transforms.lbwh_to_bbox
?
thanks
Eric
John Hunter wrote
> def ondraw(event):
> l,b,w,h = t.get_window_extent(event.renderer).get_bounds()
>
> figw, figh = fig.figwidth.get(), fig.figheight.get()
> # expand the rectangle to account for larger text; coords are pixel space
> ondraw.bbox = matplotlib.transforms.lbwh_to_bbox(
> l-10, b-10, w+200, h+20)
> ondraw.background = fig.canvas.copy_from_bbox(ondraw.bbox)
> ondraw.background = None
> ondraw.bbox = None
> 
From: Christopher B. <Chr...@no...> - 2006年12月29日 18:26:48
Achim Gaedke wrote:
> For a print button in matplotlib it is necessary to find implementations
> for other widget sets:
> * tk
> * wx
> * qt
wx has pretty good print support. However, with the wx back-end, you'd 
need to decide if you want to send the bitmap Agg created to the 
printer, or revert to using wx Drawing calls. And someone still has to 
write the code ---
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: John H. <jdh...@ac...> - 2006年12月29日 18:03:36
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
 Eric> Hi, thanks for this useful and quick answer. I am (always)
 Eric> using GTKAgg (hope it is a good choice). I understand the 40
 Eric> Mb part then, but not the 150-200 Mb... (this happens when I
 Eric> move the cursor within the figure window only and things get
 Eric> worse when I reload the data with a new imshow).
 Eric> Two things from what you say:
 Eric> * first : should I do something before redoing another
 Eric> imshow? (when I cycle many times through the 3 commands,
 Eric> connect, disconnect, imshow, the mouse event updating gets
 Eric> really slow, and in fact it seems only the "imshow" really
 Eric> makes things worse..). Maybe I need to "flush" the old
 Eric> data/image/imshow ?
If you are doing multiple imshows and not clearing the axes in between
then you may be overplotting multiple images. Make sure you clear
your axes before plotting a new image
 ax.cla()
 Eric> * second: I tried to understand what you mentioned in your
 Eric> email about the blit thing. I understand the "principle",
 Eric> reading the wiki, and going into mpl examples, but I didn"t
 Eric> manage to implement it in practice (see my pathetic attempt
 Eric> below). I guess the main reason is that I am not sure what
 Eric> should be the "background" in the case of a figtext... (not
 Eric> ax.bbox I guess but then what?)
You would want to pick a rectangle large enough to hold any text you
may want to plot to an area, and the copy and blit just that region.
Here are two examples: the first redraws the entire figure as you are
doing but reports memory. I find that memory grows for a while but
them stabilizes, and if you throw in a gc.collect() it is rock solid.
Uncomment gc.collect to compare
The second script uses the blitting technique -- you'll appreciate the
performance boost!
### script one, draw the whole thing every time
import os, sys, time, gc
import matplotlib
#matplotlib.interactive(True)
#matplotlib.use('Cairo')
matplotlib.use('GTKAgg')
import matplotlib.transforms
from pylab import figure, show, nx
def report_memory(i):
 pid = os.getpid()
 a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
 print i, ' ', a2[1],
 return int(a2[1].split()[1])
fig = figure()
ax = fig.add_subplot(111)
X = nx.mlab.randn(100,100)
ax.imshow(X)
t = ax.text(20,20,'test: 0')
def onmove(event):
 mem = report_memory(onmove.cnt)
 t.set_text('test: %d mem=%d'%(onmove.cnt, mem))
 fig.canvas.draw_idle()
 onmove.cnt +=1
 #gc.collect()
onmove.cnt = 0
fig.canvas.mpl_connect('motion_notify_event', onmove)
show()
### script two, just blit the text region
import os, sys, time
import matplotlib
#matplotlib.interactive(True)
#matplotlib.use('Cairo')
matplotlib.use('GTKAgg')
import matplotlib.transforms
from pylab import figure, show, nx
def report_memory(i):
 pid = os.getpid()
 a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
 print i, ' ', a2[1],
 return int(a2[1].split()[1])
fig = figure()
ax = fig.add_subplot(111)
X = nx.mlab.randn(100,100)
ax.imshow(X)
t = ax.text(20,20,'test: 0', animated=True)
def ondraw(event):
 l,b,w,h = t.get_window_extent(event.renderer).get_bounds()
 figw, figh = fig.figwidth.get(), fig.figheight.get()
 # expand the rectangle to account for larger text; coords are pixel space
 ondraw.bbox = matplotlib.transforms.lbwh_to_bbox(
 l-10, b-10, w+200, h+20)
 ondraw.background = fig.canvas.copy_from_bbox(ondraw.bbox)
ondraw.background = None
ondraw.bbox = None
def onmove(event):
 mem = report_memory(onmove.cnt)
 t.set_text('test: %d mem=%d'%(onmove.cnt, mem))
 if ondraw.background is not None:
 fig.canvas.restore_region(ondraw.background)
 ax.draw_artist(t)
 fig.canvas.blit(ondraw.bbox)
 onmove.cnt +=1
onmove.cnt = 0
fig.canvas.mpl_connect('motion_notify_event', onmove)
fig.canvas.mpl_connect('draw_event', ondraw)
show()
JDH
From: Jeff W. <js...@fa...> - 2006年12月29日 17:10:28
Petr Danecek wrote:
> Beautiful! The grid lines must be drawn manually?
>
> On Thu, 2006年12月28日 at 13:32 -0700, Jeff Whitaker wrote:
> 
>> Here's a slightly prettier version of my previous example:
>>
>> from pylab import *
>> deltatheta = 2.*pi/100.
>> theta = arange(0.,2.*pi+0.5*deltatheta,deltatheta)
>> R = arange(0.,pi,deltatheta)
>> r,t = meshgrid(R, theta)
>> Z = sin(r)*sin(3.*t)
>> X = r*cos(t)
>> Y = r*sin(t)
>> ax = subplot(111)
>> cs = ax.contourf(X,Y,Z)
>> # make sure aspect ratio preserved
>> ax.set_aspect('equal')
>> # turn off rectangular frame.
>> ax.set_frame_on(False)
>> # turn off axis ticks.
>> ax.set_xticks([])
>> ax.set_yticks([])
>> # draw a circle around the edge of the plot.
>> rmax = max(R)
>> ax.plot(rmax*cos(theta),rmax*sin(theta),'k')
>> title('Polar contours')
>> show()
>>
>> 
Petr: Another option might be to use pcolor, it does work wit polar axes.
import pylab
# make color-filled plot of polar coordinate data array.
# define coordinates.
theta = pylab.linspace(0.,2.*pylab.pi,101)
R = pylab.linspace(0.,pylab.pi,101)
Y,X = pylab.meshgrid(R, theta)
# data to plot.
Z = pylab.sin(Y)*pylab.sin(4*X) + pylab.exp(-(Y**2/4))
# create subplot.
ax = pylab.subplot(111,polar=True)
# mesh fill.
ax.pcolormesh(X,Y,Z)
# make sure aspect ratio preserved
ax.set_aspect('equal')
pylab.show()
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Eric E. <ems...@ob...> - 2006年12月29日 16:13:20
Hi again,
thinking about the module I am writing which will include a "move mouse
event" to get the intensity of the pixel in an imshow provided in the
figure I am wondering:
- would it make any sense to DIRECTLY include such a facility (intensity
of pixel provided for an imshow, figimage...) NEXT to the coordinates x
& Y which are already there (in the lower right) in mpl figures ????
To me (at least) it would make a LOT of sense, since x,y are already
provided for any plot, or imshow-like commands. The third axis
(intensity) would then only appear when there is a third dimension is
available of course (imshow, etc). I can imagine that such a facility
could be turned on or off (I guess...).
no?
Eric
From: Eric E. <ems...@ob...> - 2006年12月29日 16:01:52
Hi,
thanks for this useful and quick answer. I am (always) using GTKAgg
(hope it is a good choice). I understand the 40 Mb part then, but not
the 150-200 Mb... (this happens when I move the cursor within the figure
window only and things get worse when I reload the data with a new imshow).
Two things from what you say:
* first : should I do something before redoing another imshow? (when I
cycle many times through the 3 commands, connect, disconnect, imshow,
the mouse event updating gets really slow, and in fact it seems only the
"imshow" really makes things worse..). Maybe I need to "flush" the old
data/image/imshow ?
* second: I tried to understand what you mentioned in your email about
the blit thing. I understand the "principle", reading the wiki, and
going into mpl examples, but I didn"t manage to implement it in practice
(see my pathetic attempt below). I guess the main reason is that I am
not sure what should be the "background" in the case of a figtext...
(not ax.bbox I guess but then what?)
Any help is welcome (or a hint, since doing it myself is I guess the
best way to learn ...)
thanks again
Eric
#===================================================
# This script is not working... something I didn't understand in
blitting....
#===================================================
import numpy as num
import matplotlib as mpl 
import matplotlib.pylab as plab
data = num.random.rand(200,200)
xy = [num.arange(0.,20,.1), num.arange(0.,20,.1)]
fig = plab.figure()
canvas = fig.canvas
im = plab.imshow(data, extent=[0.,20.,0.,20.])
ftext = plab.figtext(0.9,0.9,"", animated=True)
ax = plab.gca()
background = canvas.copy_from_bbox(ax.bbox)
def whichpix_inframe(coord) :
 indw = num.zeros(2, num.int32)
 if len(coord) == 2 :
 indw[0] = num.sort(xy[0]).searchsorted(coord[0])
 indw[1] = num.sort(xy[1]).searchsorted(coord[1])
 return indw
def mouse_move(event) :
 if event.inaxes :
 canvas.restore_region(background)
 ftext.set_text(str(data[tuple(whichpix_inframe([event.xdata,
event.ydata]))]))
 ax.draw_artist(ftext)
 canvas.blit(ax.bbox)
# canvas.draw()
id = canvas.mpl_connect('motion_notify_event', mouse_move)
canvas.mpl_disconnect(id)
John Hunter wrote:
> Eric> 2/ When I now use the mouse_move event, it can go up to 150
> Eric> Mb of memory usage!! Again: is that normal?
>
> In your example code below, I notice you are drawing on every mouse
> motion. I believe there is a Tkinter specific leak in TkAgg if memory
> serves, but it's outside of mpl. What backend are you using? Does
> the problem go away with a different backend?
...
> The basic idea is to capture the background as a pixel buffer,
> identify the rectangle region you want to draw the text into, draw the
> background, update the text, redraw only the text rectangle etc....
> See 
>
> http://www.scipy.org/Cookbook/Matplotlib/Animation
From: Jeff W. <js...@fa...> - 2006年12月29日 16:00:02
Petr Danecek wrote:
> Beautiful! The grid lines must be drawn manually?
>
> On Thu, 2006年12月28日 at 13:32 -0700, Jeff Whitaker wrote:
> 
>> Here's a slightly prettier version of my previous example:
>>
>> from pylab import *
>> deltatheta = 2.*pi/100.
>> theta = arange(0.,2.*pi+0.5*deltatheta,deltatheta)
>> R = arange(0.,pi,deltatheta)
>> r,t = meshgrid(R, theta)
>> Z = sin(r)*sin(3.*t)
>> X = r*cos(t)
>> Y = r*sin(t)
>> ax = subplot(111)
>> cs = ax.contourf(X,Y,Z)
>> # make sure aspect ratio preserved
>> ax.set_aspect('equal')
>> # turn off rectangular frame.
>> ax.set_frame_on(False)
>> # turn off axis ticks.
>> ax.set_xticks([])
>> ax.set_yticks([])
>> # draw a circle around the edge of the plot.
>> rmax = max(R)
>> ax.plot(rmax*cos(theta),rmax*sin(theta),'k')
>> title('Polar contours')
>> show()
>>
>> 
>
> 
Petr: Yes. matplotlib has polar axes for some kinds of plots, but not 
for contour plots.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Petr D. <da...@uc...> - 2006年12月29日 15:47:22
Beautiful! The grid lines must be drawn manually?
On Thu, 2006年12月28日 at 13:32 -0700, Jeff Whitaker wrote:
> Here's a slightly prettier version of my previous example:
> 
> from pylab import *
> deltatheta = 2.*pi/100.
> theta = arange(0.,2.*pi+0.5*deltatheta,deltatheta)
> R = arange(0.,pi,deltatheta)
> r,t = meshgrid(R, theta)
> Z = sin(r)*sin(3.*t)
> X = r*cos(t)
> Y = r*sin(t)
> ax = subplot(111)
> cs = ax.contourf(X,Y,Z)
> # make sure aspect ratio preserved
> ax.set_aspect('equal')
> # turn off rectangular frame.
> ax.set_frame_on(False)
> # turn off axis ticks.
> ax.set_xticks([])
> ax.set_yticks([])
> # draw a circle around the edge of the plot.
> rmax = max(R)
> ax.plot(rmax*cos(theta),rmax*sin(theta),'k')
> title('Polar contours')
> show()
> 
From: John H. <jdh...@ac...> - 2006年12月29日 14:44:31
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
 Eric> Questions and problems: 1/ when I load the image the first
 Eric> time (first imshow command in the script), I see that,
 Eric> although the amount of data is very small,
 Eric> ipython/matplotlib already uses more than 40 Mb of memory!
 Eric> Is that normal?
It seems high, but looks inline with the size of the mpl extension
code (though some of which is redunant numpy/numeric/numarray extensions
that shouldn't all be loaded)
peds-pc311:~/mpl/build> du -h
20M ./lib.linux-i686-2.4/matplotlib/backends
8.0K ./lib.linux-i686-2.4/matplotlib/toolkits
8.0K ./lib.linux-i686-2.4/matplotlib/numerix/mlab
8.0K ./lib.linux-i686-2.4/matplotlib/numerix/ma
8.0K ./lib.linux-i686-2.4/matplotlib/numerix/linear_algebra
8.0K ./lib.linux-i686-2.4/matplotlib/numerix/random_array
8.0K ./lib.linux-i686-2.4/matplotlib/numerix/fft
64K ./lib.linux-i686-2.4/matplotlib/numerix
40K ./lib.linux-i686-2.4/matplotlib/enthought/traits/ui/null
252K ./lib.linux-i686-2.4/matplotlib/enthought/traits/ui
632K ./lib.linux-i686-2.4/matplotlib/enthought/traits
28K ./lib.linux-i686-2.4/matplotlib/enthought/resource
12K ./lib.linux-i686-2.4/matplotlib/enthought/util
676K ./lib.linux-i686-2.4/matplotlib/enthought
40M ./lib.linux-i686-2.4/matplotlib
40M ./lib.linux-i686-2.4
40M 
 Eric> 2/ When I now use the mouse_move event, it can go up to 150
 Eric> Mb of memory usage!! Again: is that normal?
In your example code below, I notice you are drawing on every mouse
motion. I believe there is a Tkinter specific leak in TkAgg if memory
serves, but it's outside of mpl. What backend are you using? Does
the problem go away with a different backend?
If there is a leak under our control we will certainly find it an fix
it to the best of our abilities. Our canonical memory leak checking
script (which does an imshow and more) is running rock solid on the
Agg backend so if there is a leak it is probably backend specific.
I noticed in your example script that you are only modifiying a text
entry on mouse motion. Your performance will dramatically improve if
you use the blitting techniques described in the animation tutorial.
The basic idea is to capture the background as a pixel buffer,
identify the rectangle region you want to draw the text into, draw the
background, update the text, redraw only the text rectangle etc....
See 
 http://www.scipy.org/Cookbook/Matplotlib/Animations
After you've read through this if you get stuck let me know and I'll
put together a small demo for you.
JDH
From: Eric E. <ems...@ob...> - 2006年12月29日 13:31:50
Hi,
I am writing a small module to easily load images and interact with
them. I now face a memory usage +CPU problem, which may in fact be the
result of a normal behaviour of matplotlib (but more certainly something
I am not doing right), but I really like to be sure here because if
confirmed, it would mean that this module is almost not usable for large
images...
Below is a (very simplified) example of what I am doing, that script
showing a similar behaviour than the real full module.
Questions and problems:
1/ when I load the image the first time (first imshow command in the
script), I see that, although the amount of data is very small,
ipython/matplotlib already uses more than 40 Mb of memory!
Is that normal?
2/ When I now use the mouse_move event, it can go up to 150 Mb of memory
usage!! Again: is that normal?
3/ When I do successive cycles of connect, disconnect, imshow (reloading
the figure), the memory usage seems to grow slightly, but more
importantly the capturing event (writing the data intensity on the top
right corner of the figure) gets REALLY SLOW.. Try a series of 10 imshow
with the same data..
So maybe I should "clean" some structure somewhere to allow a fast
interaction, or maybe the code below is rubish. But so far I haven't
found a cure, and this is very annoying to say the least.
Thanks for any tip on this problem.
Eric
P.S.: and for the sake of tempering the questions above (certainly
caused by my ignorance): matplotlib + numpy is just an amazing
combination!!!
P.P.S: set up for me is:
Suse 10.1
matplotlib version 0.87.7
numerix numpy 1.0.2.dev3491
Python 2.4.2 (#1, May 2 2006, 08:13:46)
IPython 0.7.4.svn.r2010 -- An enhanced Interactive Python.
## ===============================
## Below is a small script to illustrate memory and CPU pbs
## It loads some rand data, with coordinates given in xy
## and the mouse event allows to write the intensity of
## the image in the top right corner of the figure
## ===============================
import numpy as num
import matplotlib as mpl 
import matplotlib.pylab as plab
data = num.random.rand(200,200)
xy = [num.arange(0.,20,.1), num.arange(0.,20,.1)]
fig = plab.figure()
canvas = fig.canvas
plab.imshow(data, extent=[0.,20.,0.,20.])
ftext = plab.figtext(0.9,0.9,"")
def whichpix_inframe(coord) :
 indw = num.zeros(2, num.int32)
 if len(coord) == 2 :
 indw[0] = num.sort(xy[0]).searchsorted(coord[0])
 indw[1] = num.sort(xy[1]).searchsorted(coord[1])
 return indw
def mouse_move(event) :
 if event.inaxes :
 ax = event.inaxes
 ftext.set_text(str(data[tuple(whichpix_inframe([event.xdata,
event.ydata]))]))
 canvas.draw()
id = canvas.mpl_connect('motion_notify_event', mouse_move)
## then we can go on and cycle through the next 3 lines...: it shows the
CPU+memory pb getting worse
# canvas.mpl_disconnect(id)
# plab.imshow(data, extent=[0.,20.,0.,20.])
# id = canvas.mpl_connect('motion_notify_event', mouse_move)
From: Eric F. <ef...@ha...> - 2006年12月29日 08:14:42
John Hunter wrote:
>>>>>> "Eric" == Eric Firing <ef...@ha...> writes:
> Eric> either, indistinguishably from the way it does now. The
> Eric> problem is that with a linear axis we want the axis to start
> Eric> at zero by default, but with a log axis we want it to start
> 
> With ymin at 1e-100, the default (linear) locator should choose 0 as
> ymin. If it doesn't it looks like a bug. Is either the log or linear
> autoscaler broken for bottom=something-really-small ?
> 
> JDH
The problem is not the linear case but the log, and it is not a problem 
with the locators or with the autoscaling methods. Rather, for the log 
scale we want the autoscaling to ignore the bottom of the patches at 
1e-100 and instead pick a lower value for plotting based on the tops of 
the patches (or the bottom of the errorbars, if present). This is what 
I have it doing now via the somewhat clumsy method of adjusting the 
dataLim after the patches have been added. To make the transition to a 
log scale work correctly after bar has been called with a linear scale, 
some such adjustment would have to be made. This is the sort of thing 
that could be done by registering a callback, but we don't have the 
machinery in place. Maybe this is a place where traits would help? 
I've never used them, but I seem to recall seeing that they include 
callback functionality.
Eric
6 messages has been excluded from this view by a project administrator.

Showing results of 339

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