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


Showing results of 214

<< < 1 2 3 4 5 .. 9 > >> (Page 3 of 9)
From: Leighton P. <lp...@sc...> - 2005年03月23日 14:53:06
Hi,=0D=0A=0D=0AI'm having difficulty producing dynamic plots on OS X using =
matplotlib=0D=0A0.73.1 and wxPython 2.5.3.1 on OS X 10.3 with Python 2.3.5=0D=
=0A=0D=0AThe code below works with the same configuration on Fedora Core 3,=0D=
=0Aproducing a graph with a line that pivots at the origin. On OS X,=0D=0A=
however, the frame remains blank and grey until the final plot is drawn,=0D=
=0Awhen the plot takes on the correct final state.=0D=0A=0D=0AI've tried si=
milar examples with bar graphs and scatter plots, and the=0D=0Asame results=
 are produced. I don't know if this is a problem with=0D=0Amatplotlib or w=
xPython, and any help would be gratefully appreciated.=0D=0A=0D=0AIf you ne=
ed any more info to help, let me know.=0D=0A=0D=0AThe example code is:=0D=0A=0D=
=0A----------------=0D=0A=0D=0Aimport matplotlib=0D=0Amatplotlib.use("WXAgg=
")=0D=0Amatplotlib.interactive(True)=0D=0Afrom matplotlib.backends.backend_=
wx import FigureCanvasWx=0D=0Afrom matplotlib.figure import Figure=0D=0Afro=
m matplotlib.axes import Subplot=0D=0A=0D=0Afrom Numeric import pi, sin, ar=
ange=0D=0A=0D=0Aimport wx=0D=0A=0D=0A=0D=0Aclass PlotFigure(wx.Frame):=0D=0A=
 def __init__(self):=0D=0A wx.Frame.__init__(self, None, -1, "Tes=
t embedded wxFigure")=0D=0A=0D=0A self.fig =3D Figure((5,4), 75)=0D=0A=
 self.canvas =3D FigureCanvasWx(self, -1, self.fig)=0D=0A=0D=0A =
 sizer =3D wx.BoxSizer(wx.VERTICAL)=0D=0A sizer.Add(self.canvas, 1=
, wx.LEFT|wx.TOP|wx.GROW)=0D=0A self.SetSizer(sizer)=0D=0A se=
lf.Fit()=0D=0A=0D=0A def init_plot_data(self):=0D=0A self.a =3D s=
elf.fig.add_subplot(111)=0D=0A x =3D arange(0,2*pi,0.01) #=
 x-array=0D=0A self.a.set_xlim((0., 2*pi))=0D=0A self.a.set_y=
lim((-1., 1.))=0D=0A self.line, =3D self.a.plot(x,x)=0D=0A=0D=0A =
def update_data(self, i):=0D=0A self.line.set_ydata(self.line.get_xd=
ata()*0.01*i)=0D=0A self.canvas.draw()=0D=0A=0D=0A=0D=0Aif __name__ =
=3D=3D '__main__':=0D=0A app =3D wx.PySimpleApp(0)=0D=0A frame =3D Pl=
otFigure()=0D=0A frame.Show(True)=0D=0A frame.init_plot_data()=0D=0A =
 for i in arange(1,200):=0D=0A frame.update_data(i)=0D=0A app.M=
ainLoop()=0D=0A=0D=0A=0D=0A=0D=0A--=20=0D=0ADr Leighton Pritchard AMRSC=0D=0A=
D131, Plant-Pathogen Interactions, Scottish Crop Research Institute=0D=0AIn=
vergowrie, Dundee, Scotland, DD2 5DA, UK=0D=0AT: +44 (0)1382 562731 x2405 F=
: +44 (0)1382 568578=0D=0AE: lp...@sc... W: http://bioinf.scri=
=2Esari.ac.uk/lp=0D=0AGPG/PGP: FEFC205C E58BA41B http://www.keyserver.net =
 =20=0D=0A(If the signature does not verify, please remove the SC=
RI disclaimer)=0D=0A_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _=
 _ _ _ _ _ _ _ _ _ _=0D=0A=0D=0ADISCLAIMER:=0D=0A=0D=0AThis email is from t=
he Scottish Crop Research Institute, but the views=20=0D=0Aexpressed by the=
 sender are not necessarily the views of SCRI and its=20=0D=0Asubsidiaries.=
 This email and any files transmitted with it are confidential=20=0D=0Ato =
the intended recipient at the e-mail address to which it has been=20=0D=0Aa=
ddressed. It may not be disclosed or used by any other than that addressee=
=2E=0D=0AIf you are not the intended recipient you are requested to preserv=
e this=20=0D=0Aconfidentiality and you must not use, disclose, copy, print =
or rely on this=20=0D=0Ae-mail in any way. Please notify pos...@sc...=
ri.ac.uk quoting the=20=0D=0Aname of the sender and delete the email from y=
our system.=0D=0A=0D=0AAlthough SCRI has taken reasonable precautions to en=
sure no viruses are=20=0D=0Apresent in this email, neither the Institute no=
r the sender accepts any=20=0D=0Aresponsibility for any viruses, and it is =
your responsibility to scan the email=20=0D=0Aand the attachments (if any).=0D=
=0A
From: Travis B. <td...@fa...> - 2005年03月22日 22:54:02
Hi all,
I'm making a plot with two axes (axUpper and axLower) that is a bit of a
copy of John's financial plot in
http://matplotlib.sourceforge.net/screenshots/finance_work2.py.
axUpper has it's y axis on the left and axLower has it on the right and
each of these sets of labels has an extraneous bit of a date label on
it.
axUpper has a chunk of 'February' at the point where axUpper and axLower
meet and the axLower labels have an extra bit of '02' at the same spot.
Anyone have an idea of why that might be?
Thanks,
Travis
-- 
 Travis Brady
 td...@fa...
From: Darren D. <dd...@co...> - 2005年03月22日 22:43:23
Hi,
I havent had trouble with this. Could you first make sure that you are 
changing your rc settings before importing from pylab? This works for my on 
MPL 0.72.1, python 2.3:
import matplotlib
matplotlib.rcParams['tick.labelsize']=6
from pylab import *
plot([1,2,3,4])
show()
If that doesnt work, please post a short script that will reproduce the 
behavior.
Darren
On Tuesday 22 March 2005 05:17 pm, Haibao Tang wrote:
> rcParams['tick.labelsize'] is not working? How to set tick label size in
> another way? py23 + pylab07
>
> Thanks.
From: Russell E. O. <ro...@ce...> - 2005年03月22日 22:22:53
We'd like to set up a set of plots that look something like:
PPPP PPPP PPPP
PPPP PPPP PPPP
PPPP PPPP PPPP
PPPP PPPP PPPP
hhh s...
hhhhh s...
hhh s...
hhhhhh s.....
where
- each set of Ps is a 4x4 pcolor plot representing signal
 on a 4x4 detector at a particular time. I.e. a 4x4
 array of solid blocks of gray.
- h is a histogram
- s is the left edge of a scatter plot/strip chart
We have the basic layout, but are missing a few subtleties...
If possible, when the window is resized we'd like to:
- Resize the histogram and scatterplots but not the pcolor plots. (After 
all, there's no detail to zoom into in a 4x4 pcolor plot!)
- Keep the pcolor plots (Ps) square.
My first thought was to set up multiple FigureCanvas objects and use 
tk's layout options. But the updating then looked funny (and seemed to 
go slower, though that may be my imagination). We're updating the 
displays at 2 Hz (for data coming in at 20Hz) and all the plots are 
related, so it's important to update them all at the same time.
Any hints would be appreciated.
-- Russell
P.S. when using the TkAgg API, is this the usual idiom for turning off 
axis labels?:
 yls = self.axScatter.get_yticklabels()
 for yl in yls:
 yl.set_visible(False)
I did not find any equivalent to the pylab.set command that 
automatically iterates over collections of ticks or labels. No big deal, 
but I'd simplify the code if I could.
From: Haibao T. <ba...@ug...> - 2005年03月22日 22:17:45
rcParams['tick.labelsize'] is not working? How to set tick label size in =
another way?
py23 + pylab07
Thanks.
From: Humufr <hu...@ya...> - 2005年03月22日 18:53:49
 Hello,
there are something always strange for me in mathtext is the code for 
the angstrom mode. It's not the same in Latex and there are only the 
upper case symbole. Perhaps (it's only a suggestion) that will be better 
to replace \angstrom withb \AA.
Thanks for the work did in matplotlib,
 N.
From: James B. <bo...@ll...> - 2005年03月22日 17:56:32
I would like to be able to define a new colormap dynamically, that is 
without altering code in cm.py.
It would not appear to be too difficult to some one who knew what they 
were doing. I have made
some attempts following the code in cm.py and other places, but I do 
not seem to be able to get the
normalization correct.
I know that I could just put the data into cm.py but I would rather not 
have to remember to alter this code
for every release of matplotlib and I am sure most people do not want 
my colormaps.
I have used GMT (Generic Mapping Tools) extensively in the past and 
have code to translate the GMT color map
into a form usable by matplotlib.
The site: http://craik.shef.ac.uk/cpt-city/ has a very large number 
of colormaps in the GMT format and would be a useful resource for 
matplotlib,
 if the data files there could be easily imported.
Thanks for any pointers.
--JIm
From: Jean-Michel P. <jea...@ar...> - 2005年03月21日 09:58:05
Hi,
Does anyone know why Agg backend does not support non-ASCII chars? I 
think many non-English speaking users would really appreciate to be able 
to use their full alphabet in graphics ;-) while taking advantage of the 
great Agg technique.
JM. Philippe
ond...@gm... a écrit :
> Hello,
> in case someone has the same problem as me -- to display accented
> letters in matplotlib -- this is how to do it:
> 
> #! /usr/bin/python
> # -*- coding: iso-8859-2; -*-
> 
> import matplotlib
> matplotlib.use('GTK')
> from pylab import *
> plot([1,2,3])
> title(u'some accented letters: ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿')
> #savefig("pokus.eps")
> show()
> 
> Important is "use('GTK')" (Agg backend only shows rectangles instead of
> accented letters) and "title(u'some..." (the "u" -- without it it
> doesn't work either).
> 
> You can save the figure to *.png, unfortunately saving to *.eps or *.ps
> doesn't work (even using different backend).
> 
> Ondrej Certik
> 
From: Jason H. <hoo...@me...> - 2005年03月21日 08:58:51
Todd,
Thanks, your suggestion prodded me in the right direction, a good old=20
permission issue. It's all working now. Am pasting my notes below.
Jason
I tried the remedies suggested here:
http://lists.debian.org/debian-user/1998/09/msg00113.html
(xhost +localhost) and here:
http://lists.debian.org/debian-user/1998/08/msg03179.html
(use ssh which takes care of the $DISPLAY enviro variable)
In the second I no longer got the two lines at the top of the build output:
Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
But everything else went exactly the same. So then I decided to:
# chmod -R a+rwx *
within the untarred Matplotlib installation root (/matplotlib-0.72.1), to o=
pen=20
up the permissions. After again setting BUILD_GTKAGG=3D0 in setup.py I the=
n=20
ran:
> python setup.py build
as my normal (non-root) user and it went perfectly. Since my python=20
installation is in /usr/lib/python which requires root privileges to create=
=20
directories etc, I then su'd and from the same directory:
# python setup.py install
and it transferred the files etc. as desired to the python installation. I=
=20
then had to change /usr/share/matplotlib/.matplotlibrc:
\snip
#### CONFIGURATION BEGINS HERE
backend : GTKAgg # the default backend
numerix : Numeric # Numeric or numarray
interactive : False # see=20
http://matplotlib.sourceforge.net/interactive.html
toolbar : toolbar2 # None | classic | toolbar2
timezone : UTC # a pytz timezone string, eg US/Central or=20
Europe/Paris
\snip
so that the backend was set to 'TKAgg' and interactive set to 'True'. It=20
didn't like 'TKAgg', it needs 'TkAgg'. I confirmed operation with:
python>>> from pylab import *
python>>> plot([1,2,3])
python>>> [<matplotlib.lines.Line2D instance at 0x40479a2c>]
and the Tk window comes up and is zoomable etc. Looks good, looks like the=
=20
effort might be worth it!=20
On Saturday 19 March 2005 00:23, Todd Miller wrote:
> On Fri, 2005年03月18日 at 05:02, Jason Hoogland wrote:
> > Second question: I can't install Matplotlib and maybe someone will have
> > seen the symptom before or have some bright ideas to help me figure it
> > out. I'm running SuSE 9.1, python 2.3.3, and seem to have Tcl/Tk/Tkint=
er
> > installed OK.
> >
> > I set BUILD_GTKAGG =3D 0 in setup.py. In an xterm as root I ran this a=
nd
> > the output follows
> >
> > \start
> >
> > # python setup.py build
> > Xlib: connection to ":0.0" refused by server
> > Xlib: Invalid MIT-MAGIC-COOKIE-1 key
> > Using default library and include directories for Tcl and Tk because a
> > Tk window failed to open. You may need to define DISPLAY for Tk to work
> > so that setup can determine where your libraries are located.
> > running build
> > running build_py
> > creating build
> > creating build/lib.linux-i686-2.3
> > copying lib/pylab.py -> build/lib.linux-i686-2.3
> > creating build/lib.linux-i686-2.3/matplotlib
> > copying lib/matplotlib/patches.py -> build/lib.linux-i686-2.3/matplotlib
> > copying lib/matplotlib/_image.py -> build/lib.linux-i686-2.3/matplotlib
> >
> > ... etc copying a bunch of files into the build directory
>
> [mostly snipped]
>
> > g++ -pthread -shared build/temp.linux-i686-2.3/src/_tkagg.o
> > -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/lib
> > -L/usr/local/lib -L/usr/lib -ltk -ltcl -lpng -lz -lstdc++ -lm -lfreetype
> > -lz -lstdc++ -lm -o
> > build/lib.linux-i686-2.3/matplotlib/backends/_tkagg.so
> > /linux1/usr/bin/../lib/gcc-lib/i586-suse-linux/3.3.3/../../../../i586-s=
us
> >e-linux/bin/ld: cannot find -ltk
> > collect2: ld returned 1 exit status
> > error: command 'g++' failed with exit status 1
> >
> > \end
> >
> > I'm figuring the "Tk window open failed" bit at the start is just becau=
se
> > it seems to take a few seconds for Tk windows to appear on my system, a=
nd
> > its not coded to wait.
>
> That "Tk window open failed" problem looks to me like it may be *the*
> problem. matplotlib opens a Tk window to help figure out where Tk is;
> the fallback isn't working. In your case I think the Tk window failed
> because "root" is trying to open a window on a display owned by your
> non-priviledged account. Having the system say "no" to root about
> anything is really counter intuitive to me, but I've experienced it
> myself and it's discussed some here:
>
> http://lists.debian.org/debian-user/1998/09/msg00113.html
>
> The article suggests that if you do
>
> % xhost +localhost
>
> in your non-priviledged account before trying to build as root, X will
> allow the Tk window open.
>
> > So assuming that's not fatal, it seems the problem boils
> > down to "cannot find -ltk". I have searched for a few hours on google =
to
> > no avail. The only things I can suspect are maybe:
> >
> > - I might be missing some installed components for development stuff in
> > Tcl or g++?
>
> Maybe. On my RHEL3 system, I have tk-devel-8.3.5-92.2 installed.
>
> Hope this helps,
> Todd
=2D-=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
Jason Hoogland =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0h...@me...
Doctoral student =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ph(=
w) +61 7 3365 4457
Centre for Hypersonics =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ph(mob) +61 413 30=
0 887
The University of Queensland =C2=A0 =C2=A0UTC+10
Brisbane QLD 4072, Australia =C2=A0 =C2=A0http://www.marsgravity.org
=2D---------------------------------------------------------
From: Paul B. <ba...@st...> - 2005年03月20日 15:08:01
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
 <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Yang Yang wrote:
<blockquote
 cite="mid...@ms..."
 type="cite">
 <meta http-equiv="Content-Type" content="text/html; ">
 <meta name="Generator" content="Microsoft Word 11 (filtered medium)">
 <style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:SimSun;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:SimSun;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:Arial;
	color:windowtext;}
 /* Page Definitions */
 @page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	layout-grid:15.6pt;}
div.Section1
	{page:Section1;}
-->
 </style>
 <div class="Section1" style="">
 <p class="MsoNormal"><font face="Arial" size="1"><span
 style="font-size: 9pt; font-family: Arial;" lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I
have a long annoying problem: how can I make the installer compile for
numarray
instead of Numeric? For compatibility reason I have both on my machine
and
prefer numarray (and an installer</span></font><font face="Wingdings"
 size="1"><span style="font-size: 9pt; font-family: Wingdings;"
 lang="EN-US">J</span></font><font face="Arial" size="1"><span
 style="font-size: 9pt; font-family: Arial;" lang="EN-US">).
It seems the installer detects the presence of Numeric prior to
numarray. Is
there any configuration available? Thanks.<o:p></o:p></span></font></p>
 </div>
</blockquote>
The matplotlib setup.py file looks for both Numeric and Numarray and
sets the build configuration to 'both', if you have them. This is your
situation, so you should have access to both of them. If it is not
finding Numarray, then you'll have to modify your PYTHONPATH variable
to point to the numarray library. Also make sure you have the numarray
include files.<br>
<br>
To use numarray, set the numerix keyword to numarray in your
.matplotlibrc file.<br>
<br>
&nbsp;-- Paul<br>
<pre class="moz-signature" cols="72">-- 
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218
</pre>
</body>
</html>
From: Ondrej C. <ond...@gm...> - 2005年03月20日 12:29:23
Hello,
in case someone has the same problem as me -- to display accented
letters in matplotlib -- this is how to do it:
#! /usr/bin/python
# -*- coding: iso-8859-2; -*-
import matplotlib
matplotlib.use('GTK')
from pylab import *
plot([1,2,3])
title(u'some accented letters: =C4=9B=C5=A1=C4=8D=C5=99=C5=BE=C3=BD=C3=A1=
=C3=A1=C3=AD=C3=A9')
#savefig("pokus.eps")
show()
Important is "use('GTK')" (Agg backend only shows rectangles instead of
accented letters) and "title(u'some..." (the "u" -- without it it
doesn't work either).
You can save the figure to *.png, unfortunately saving to *.eps or *.ps
doesn't work (even using different backend).
Ondrej Certik
From: Yang Y. <f-...@ms...> - 2005年03月20日 09:00:23
Hi,
 I have a long annoying problem: how can I make the installer
compile for numarray instead of Numeric? For compatibility reason I have
both on my machine and prefer numarray (and an installer:-)). It seems
the installer detects the presence of Numeric prior to numarray. Is
there any configuration available? Thanks.
=20
Cheers,
Yang
=20
John,
Below is a version of the script that works. The problem is windows does 
not put out binary. The example in the matplotlib documentation should 
be updated to point out this machine compatibility issue unless someone 
knows a better way.
#!d:/apps/Python23/python
import os, sys, msvcrt
from pylab import *
plot([1,2,3,4])
print "Content-type: image/png\n"
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
savefig(sys.stdout)
Best wishes, Simon
Simon Hook wrote:
> John,
>
> I have reduced the python script to 4 lines which no longer includes 
> matplotlib but it still does not work (see below). I have tried many 
> permutations - none work. If you can get this to work, under 
> Apache-windows. I would really appreciate knowing how. This capability 
> would be useful for displaying images from matplotlib.
>
> #!d:/apps/Python23/python.exe
>
> fp = open('tmp.png','rb')
> print "Content-type: image/png\n"
> print fp.read()
> fp.close()
>
> Tthe script generates is:
>
> The image "http://shook-m2/cgi-bin/plot.py" cannot be displayed, 
> because it contains errors.
>
> plot.py is the name of the script, tmp.png is a png in the cgi-bin 
> directory.
>
> I am using:
> Python 2.3 (Enthought version)
> Apache 2.0.53
> Windows XP Sp2
>
> The script is in cgi-bin. Other python scripts work fine e.g. hello 
> world.
>
> Cheers, Simon
>
> John Hunter wrote:
>
>>>>>>> "Simon" == Simon Hook <sim...@jp...> writes:
>>>>>>> 
>>>>>>
>>
>> Simon> Hi, The code below when run from a file in the cgi-bin
>> Simon> directory should generate a plot but it does not work:
>>
>> It would help to have more information. What do you mean "does not
>> work"? Are there any errors displayed to the terminal or apache
>> logs. I know people have used mpl with apache, but it can be a little
>> tricky to get all the data paths set up properly. 
>> matplotlib uses a couple of environment variables to find it's data
>> and store cache information. For example, if your fonts and
>> .matplotlibrc are in a nonstandard place, you need to set the env var
>> MATPLOTLIBDATA to point to them. Also, mpl tries to create a cache
>> file .ttffont.cache in your HOME dir by default, and in an apache
>> config HOME may not exist or may not be writable. If there is no
>> HOME, matplotlib will fall back on the MATPLOTLIBDATA dir, so make
>> sure env var is set, that it points to the directory that contains
>> Vera.ttf and the other mpl fonts, and that it is writable by the user
>> under which apache runs.
>>
>> If you get this to work, please write a HOWTO and submit it to the list.
>>
>>
>> Simon> #!d:/apps/Python23/python
>>
>> Simon> import sys import matplotlib matplotlib.use('Agg') from
>> Simon> pylab import *
>>
>> Simon> plot([1,2,3,4])
>>
>> Simon> #print "Content-type: text/html\n\n" #print "<html>Hello
>> Simon> world!</html>"
>>
>> Simon> print "Content-type: image/png\n\n" Simon> print 
>> savefig(sys.stdout)
>>
>> This looks wrong. Doing
>>
>> print savefig(sys.stdout)
>>
>> will also print the return value of savefig, which is None I believe.
>> I think you just want
>>
>> savefig(sys.stdout)
>>
>> But I can't vouch for the overall approach (setting the content type
>> and then dumping in a binary stream of the png). It may be correct,
>> but I haven't used it. Somehow I would expect the stream to be mime
>> or base64 encoded in an ascii file.
>>
>> Simon> However, it does not work and I am really struggling to get
>> Simon> matplotlib to generate a plot dynamically in a
>> Simon> cgi-script. If anyone has done this successfully I would
>> Simon> really appreciate some help or a simple example. I am using
>> Simon> Windows XP and Apache 2.0.53.
>>
>> Hope this helps a little -- let us know if you have any more details
>> on the problem you are experiencing or if you make any progress.
>>
>> JDH
>> 
>>
-- 
+++++++++++++++++++++++++++++++++++++++++
Simon J. Hook, MSc, PhD
Jet Propulsion Laboratory 
MS 183-501
Pasadena, CA 91109
Office: 818-354-0974
Fax: 818-354-0966
Email: sim...@jp...
http://asterweb.jpl.nasa.gov
http://masterweb.jpl.nasa.gov
http://laketahoe.jpl.nasa.gov
+++++++++++++++++++++++++++++++++++++++++ 
From: Curtis C. <cu...@hi...> - 2005年03月19日 21:10:28
Hi,
I have two questions about the basemap toolkit:
1) I use the orthographic projection often in my research. Can support
for this be easily added to basemap?
2) In the basemap.interp function, which just forwards the arguments on to
numarray.nd_image.map_coordinates, why is it necessary to enforce regular
grid spacing? It seems to me the interpolation will work either way.
Cheers,
Curtis
 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Curtis S. Cooper, Graduate Research Assistant *
 * Lunar and Planetary Laboratory, University of Arizona *
 * http://www.lpl.arizona.edu/~curtis/		 *
 * Kuiper Space Sciences, Rm. 318 *
 * 1629 E. University Blvd., *
 * Tucson, AZ 85721 * * * * * * * * * * * * * * *
 * Wk: (520) 621-1471 *
 * * * * * * * * * * * *
From: Peter G. <pgr...@ge...> - 2005年03月19日 21:06:28
I do it all the time, but instead of writing to a stream directly, I 
write to file, and embed the image in the html. This works for me, 
because (1) I need that html around to let users setup options, and (2) 
the images are available at a later date - something that has been 
plotted once can be viewed multiple times.
You basically save your plot to a file and then include something like:
<img src="/tmp/image.2005年03月19日_10-50-20.38431390.png">
in your html.
Unless you serve thousands of requests, the few ms waisted 
writing/reading to/from a file should be negligible.
Finally, you might want to look into the error log file for apache, and 
see what goes on behind the scenes. I still run 0.65 (modified) and 
remember had to setup proper permissions on a cache file before thigs 
worked.
Another thing, maybe not the case here, but worth remembering that it is 
crucial to have the 'Content-type' line be the first data written. I've 
had issues in the past where importing some libraries would write 
something else to the stream, and often would be get some criptic errror.
Cheers,
 
-- 
Peter Groszkowski Gemini Observatory
Tel: +1 808 9742509 670 N. A'ohoku Place
Fax: +1 808 9359235 Hilo, Hawai'i 96720, USA
Simon Hook wrote:
> Hi,
>
> The code below when run from a file in the cgi-bin directory should 
> generate a plot but it does not work:
>
> #!d:/apps/Python23/python
>
> import sys
> import matplotlib
> matplotlib.use('Agg')
> from pylab import *
>
> plot([1,2,3,4])
>
> #print "Content-type: text/html\n\n"
> #print "<html>Hello world!</html>"
>
> print "Content-type: image/png\n\n"
> print savefig(sys.stdout)
>
> However, it does not work and I am really struggling to get matplotlib 
> to generate a plot dynamically in a cgi-script. If anyone has done 
> this successfully I would really appreciate some help or a simple 
> example. I am using Windows XP and Apache 2.0.53.
>
> Many thanks,
>
> Simon
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
John,
I have reduced the python script to 4 lines which no longer includes 
matplotlib but it still does not work (see below). I have tried many 
permutations - none work. If you can get this to work, under 
Apache-windows. I would really appreciate knowing how. This capability 
would be useful for displaying images from matplotlib.
#!d:/apps/Python23/python.exe
fp = open('tmp.png','rb')
print "Content-type: image/png\n"
print fp.read()
fp.close()
Tthe script generates is:
The image "http://shook-m2/cgi-bin/plot.py" cannot be displayed, because 
it contains errors.
plot.py is the name of the script, tmp.png is a png in the cgi-bin 
directory.
I am using:
Python 2.3 (Enthought version)
Apache 2.0.53
Windows XP Sp2
The script is in cgi-bin. Other python scripts work fine e.g. hello world.
Cheers, Simon
John Hunter wrote:
>>>>>>"Simon" == Simon Hook <sim...@jp...> writes:
>>>>>> 
>>>>>>
>
> Simon> Hi, The code below when run from a file in the cgi-bin
> Simon> directory should generate a plot but it does not work:
>
>It would help to have more information. What do you mean "does not
>work"? Are there any errors displayed to the terminal or apache
>logs. I know people have used mpl with apache, but it can be a little
>tricky to get all the data paths set up properly. 
>
>matplotlib uses a couple of environment variables to find it's data
>and store cache information. For example, if your fonts and
>.matplotlibrc are in a nonstandard place, you need to set the env var
>MATPLOTLIBDATA to point to them. Also, mpl tries to create a cache
>file .ttffont.cache in your HOME dir by default, and in an apache
>config HOME may not exist or may not be writable. If there is no
>HOME, matplotlib will fall back on the MATPLOTLIBDATA dir, so make
>sure env var is set, that it points to the directory that contains
>Vera.ttf and the other mpl fonts, and that it is writable by the user
>under which apache runs.
>
>If you get this to work, please write a HOWTO and submit it to the list.
>
>
> Simon> #!d:/apps/Python23/python
>
> Simon> import sys import matplotlib matplotlib.use('Agg') from
> Simon> pylab import *
>
> Simon> plot([1,2,3,4])
>
> Simon> #print "Content-type: text/html\n\n" #print "<html>Hello
> Simon> world!</html>"
>
> Simon> print "Content-type: image/png\n\n" 
> Simon> print savefig(sys.stdout)
>
>This looks wrong. Doing
>
>print savefig(sys.stdout)
>
>will also print the return value of savefig, which is None I believe.
>I think you just want
>
>savefig(sys.stdout)
>
>But I can't vouch for the overall approach (setting the content type
>and then dumping in a binary stream of the png). It may be correct,
>but I haven't used it. Somehow I would expect the stream to be mime
>or base64 encoded in an ascii file.
>
> Simon> However, it does not work and I am really struggling to get
> Simon> matplotlib to generate a plot dynamically in a
> Simon> cgi-script. If anyone has done this successfully I would
> Simon> really appreciate some help or a simple example. I am using
> Simon> Windows XP and Apache 2.0.53.
>
>Hope this helps a little -- let us know if you have any more details
>on the problem you are experiencing or if you make any progress.
>
>JDH
> 
>
From: John H. <jdh...@ac...> - 2005年03月19日 12:56:20
>>>>> "Simon" == Simon Hook <sim...@jp...> writes:
 Simon> Hi, The code below when run from a file in the cgi-bin
 Simon> directory should generate a plot but it does not work:
It would help to have more information. What do you mean "does not
work"? Are there any errors displayed to the terminal or apache
logs. I know people have used mpl with apache, but it can be a little
tricky to get all the data paths set up properly. 
matplotlib uses a couple of environment variables to find it's data
and store cache information. For example, if your fonts and
.matplotlibrc are in a nonstandard place, you need to set the env var
MATPLOTLIBDATA to point to them. Also, mpl tries to create a cache
file .ttffont.cache in your HOME dir by default, and in an apache
config HOME may not exist or may not be writable. If there is no
HOME, matplotlib will fall back on the MATPLOTLIBDATA dir, so make
sure env var is set, that it points to the directory that contains
Vera.ttf and the other mpl fonts, and that it is writable by the user
under which apache runs.
If you get this to work, please write a HOWTO and submit it to the list.
 Simon> #!d:/apps/Python23/python
 Simon> import sys import matplotlib matplotlib.use('Agg') from
 Simon> pylab import *
 Simon> plot([1,2,3,4])
 Simon> #print "Content-type: text/html\n\n" #print "<html>Hello
 Simon> world!</html>"
 Simon> print "Content-type: image/png\n\n" 
 Simon> print savefig(sys.stdout)
This looks wrong. Doing
print savefig(sys.stdout)
will also print the return value of savefig, which is None I believe.
I think you just want
savefig(sys.stdout)
But I can't vouch for the overall approach (setting the content type
and then dumping in a binary stream of the png). It may be correct,
but I haven't used it. Somehow I would expect the stream to be mime
or base64 encoded in an ascii file.
 Simon> However, it does not work and I am really struggling to get
 Simon> matplotlib to generate a plot dynamically in a
 Simon> cgi-script. If anyone has done this successfully I would
 Simon> really appreciate some help or a simple example. I am using
 Simon> Windows XP and Apache 2.0.53.
Hope this helps a little -- let us know if you have any more details
on the problem you are experiencing or if you make any progress.
JDH
From: John H. <jdh...@ac...> - 2005年03月19日 02:32:30
>>>>> "Russell" == Russell E Owen <ro...@ce...> writes:
 Russell> I have some kind of error in some test code and get this
 Russell> interesting display:
Sorry, this was an undocumented change. After some discussion on
matplotlib-devel we resolved that it only confused matters to have
matplotlib trying to do custom error handling and logging, because
python has standard ways of dealing with both of these. This should
have made it into the CHANGELOG *and* the release notes, so it was an
oversight in that it made it into neither.
 * errors now raise exceptions, as they should.
 * warnings are handled by the python standard library module
 "warnings".
I think everyone on matplotlib-devel agreed after months of
intermittent discussion that this was the proper solution.
I advise you to grab the latest .matplotlibrc file from the src
distribution and copy it over to your home directory and re-customize
it. The latest version can also always be found at
http://matplotlib.sf.net/.matplotlibrc .
JDH
From: Natsu <nat...@ya...> - 2005年03月19日 02:06:14
John Hunter wrote:
> OK, I can replicate the bug on windows and linux -- thanks for the
> test file. Even though I've found where the bug is occurring -- the
> call to 
> 
> setattr("family_name", Py::String(face->family_name);
> 
> in ft2font.cpp, the fix is not immediately obvious, so we'll continue
> to work on it and I'll keep you posted. In the interim, hopefully you
> can remove the troublesome files from your font path and still use
> matplotlib.
John,
Thank you for your immidiate response.
As I had to modify Yasushi's script to find the troublesome fonts,
for the sake of possible followers, I post the modified script here as
'font_test.py'.
With this script, I did not remove the font from the system,
just added to the list 'exlude' defined in the bottom part of
the script.
The same idea worked for function createFontDict in font_manager.py,
though its a very clumsy work-around for the problem, I know.
Maybe, you can list the dangerous font in somewhere in the .rcfile, 
until the problem in ft2font.cpp is solved.
Anyway, thanks a lot. I'll start to do the plotting.
Natsu
---
def createFontDict(fontfiles, fontext='ttf'):
 """A function to create a dictionary of font file paths. The
default is to create a dictionary for TrueType fonts. An AFM font
dictionary can optionally be created.
"""
 fontdict = {}
 exclude = ['JRLM00M.TTF', ] ## modified
 # Add fonts from list of known font files.
 seen = {}
 for fpath in fontfiles:
 fname = os.path.split(fpath)[-1] ## modified
 if seen.has_key(fname): continue
 else: seen[fname] = 1
 if fontext == 'ttf':
 if fname in exclude: continue ## modified
 try:
 font = ft2font.FT2Font(str(fpath))
 except RuntimeError:
 verbose.report_error("Could not open font file %s"%fpath)
 continue
 prop = ttfFontProperty(font)
--- snip ---
----- font_test.py -----
import os
import glob
import sys
from matplotlib import rcParams
from matplotlib.ft2font import FT2Font
## from matplotlib.font_manager import findSystemFonts
## Original script failed here.
MSFolders = \
 r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
MSFontDirectories = [
 r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts',
 r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts']
def win32FontDirectory():
 """Return the user-specified font directory for Win32."""
 try:
 import _winreg
 except ImportError:
 return os.path.join(os.environ['WINDIR'], 'Fonts')
 else:
 user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders)
 try:
 return _winreg.QueryValueEx(user, 'Fonts')[0]
 finally:
 _winreg.CloseKey(user)
 return None
def findSystemFonts(fontpaths=None, fontext='ttf'):
 """Search for fonts in the specified font paths, or use the system
paths if none given. A list of TrueType fonts are returned by default
with AFM fonts as an option.
"""
 fontfiles = {}
 if fontpaths is None:
 if sys.platform == 'win32':
 fontdir = win32FontDirectory()
 fontpaths = [fontdir]
 # now get all installed fonts directly...
 for f in win32InstalledFonts(fontdir):
 base, ext = os.path.splitext(f)
 if len(ext)>1 and ext[1:].lower()==fontext:
 fontfiles[f] = 1
 else:
 fontpaths = x11FontDirectory()
 elif isinstance(fontpaths, (str, unicode)):
 fontpaths = [fontpaths]
 for path in fontpaths:
 for fname in glob.glob(os.path.join(path, '*.'+fontext)):
 fontfiles[os.path.abspath(fname)] = 1
 return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
def win32InstalledFonts(directory=None, fontext='ttf'):
 """Search for fonts in the specified font directory, or use the
system directories if none given. A list of TrueType fonts are
returned by default with AFM fonts as an option.
"""
 import _winreg
 if directory is None:
 directory = win32FontDirectory()
 key, items = None, {}
 for fontdir in MSFontDirectories:
 try:
 local = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, fontdir)
 except OSError:
 continue
 local = None
 if not local:
 return glob.glob(os.path.join(directory, '*.'+fontext))
 try:
 for j in range(_winreg.QueryInfoKey(local)[1]):
 try:
 key, direc, any = _winreg.EnumValue( local, j)
 if not os.path.dirname(direc):
 direc = os.path.join(directory, direc)
 direc = os.path.abspath(direc).lower()
 if direc[-4:] == '.'+fontext:
 items[direc] = 1
 except EnvironmentError:
 pass
 return items.keys()
 finally:
 _winreg.CloseKey(local)
 return None
paths = [rcParams['datapath']]
if os.environ.has_key('TTFPATH'):
 ttfpath = os.environ['TTFPATH']
 if ttfpath.find(';') >= 0: #win32 style
 paths.extend(ttfpath.split(';'))
 else:
 paths.append(ttfpath)
ttffiles = findSystemFonts(paths) + findSystemFonts()
exclude = ['JRLM00M.TTF', ]
for fpath in ttffiles:
 fname = os.path.split(fpath)[-1]
 if fname in exclude:
 pass
 else:
 print "probing %s" %(str(fpath))
 font = FT2Font(str(fpath))
print "all fine."
From: Russell E. O. <ro...@ce...> - 2005年03月19日 00:31:50
I have some kind of error in some test code and get this interesting 
display:
/usr/local/lib/python2.4/site-packages/matplotlib/__init__.py:641: 
UserWarning: Bad val "error" on line #199
 "verbose.level : error # one of silent, error, helpful, 
debug, debug-annoying"
 in file "/Users/rowen/.matplotlibrc"
 Illegal verbose string "error". Legal values are ('silent', 
'helpful', 'debug', 'debug-annoying')
 warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' 
% (val, cnt, line, fname, msg))
My .matplotlibrc worked fine with matplotlib 0.72.1 and 0.71 and "error" 
was certainly an accepted value.
-- Russell
From: Fernando P. <Fer...@co...> - 2005年03月18日 21:48:39
John Hunter wrote:
>>>>>>"Fernando" == Fernando Perez <Fer...@co...> writes:
> 
> 
> Fernando> Hi all, I wonder how I can get, in an easy way, the
> Fernando> number of a figure returned by a call to figure(None).
> Fernando> The nasty way is:
> 
> Fernando> allnums = [f.num for f in
> Fernando> _pylab_helpers.Gcf.get_all_fig_managers()] if allnums:
> Fernando> num = max(allnums) + 1 else: num = 1
> 
> Fernando> but this seems horrible for everyday, user-level code.
> Fernando> What I want to do is simply be able to make a call to:
> 
> Fernando> ff=figure()
> 
> Fernando> and then later make a series of plots which go to that
> Fernando> figure:
> 
> Fernando> myplotfunc(fignum=ff.num) myplotfunc2(fignum=ff.num) ...
> 
> What if we just attach the num attribute in the pylab figure function
> 
> figManager.canvas.figure.num = num
> return figManager.canvas.figure
That's pretty much what I think would be the simplest solution, and I'd be 
happy with it.
It would be nice if this little change made it into .73, along with removing 
this section from figure:
 if num==0:
 error_msg('Figure number can not be 0.\n' + \
 'Hey, give me a break, this is matlab(TM) compatability')
 return
Best,
f
From: John H. <jdh...@ac...> - 2005年03月18日 21:38:44
What's new in matplotlib 0.73
new contour functionality
 Filled contours (polygons) with contourf and clabel . See
 examples/contour_demo.py, examples/contourf_demo.py,
 examples/contour_image.py and the screenshot at
 http://matplotlib.sf.net/screenshots.html#pcolor_demo. Thanks Nadia
 and Eric for lots of hard work. This code is not perfect, so please
 let us know if you find bugs or problems.
native font support back in PS
 Added new rc param param ps.useafm so ps backend can use native
 fonts; this currently breaks PS mathtext but makes for smaller files
colorbar now a figure method
 Refactored colorbar code out of pylab into Figure API for API
 developers. matplotlib.pylab colorbar is now a thin wrapper to this
 function.
minor enhancements and bug-fixes
 Experimental support for GTK w/o double buffering, added double
 buffering to gtkagg, exposed some core agg functionality in
 matplotlib.agg, upgraded wrapper generator to CXX 5.3.1, added a
 custom pixel transfer function for GTK which works for Numeric and
 numarray, added patch for problem with Japanse fonts in windows
 registry, fixed ticks for horizontal colorbars, fixed labelsep
 legend bug
Downloads at http://matplotlib.sf.net
JDH
From: John H. <jdh...@ac...> - 2005年03月18日 21:36:04
>>>>> "Russell" == Russell E Owen <ro...@ce...> writes:
 Russell> Thanks. That was helpful -- though also a bit confusing,
 Russell> in that I'm using the TkAgg back end and calling
 Russell> pylab.draw() doesn't update anything visible on my
 Russell> FigureCanvasAgg object. (As an aside, calling show() on
 Russell> my FigureCanvasAgg object seems to work -- the code
 Russell> originally did that when I got it -- but the manual and
 Russell> FAQ clearly point to using draw instead).
I looked back over the code you posted previously and see that you are
using the API, eg making your own tk canvases. In this case you
should not import pylab at all. Do everything from the class API.
Call canvas.draw() rather than pylab.draw().
You can still use matplotlib.numerix to get all the Numeric/numarray
symbols, but the pylab interface doesn't mix well with the API
interface because pylab tries to manage figure creation and
destruction for you.
Instead of
 f = figure(figsize=(3,3)) # this is a pylab call
 sp = f.add_subplot(111)
 canvas = FigureCanvasTkAgg(f, master=root)
do 
from matplotlib.figure import Figure
 f = Figure(figsize=(3,3)) # this is an API call
 sp = f.add_subplot(111)
 canvas = FigureCanvasTkAgg(f, master=root)
See also examples/agg_oo.py and this post for a tutorial introduction
the matplotlib API
 http://sourceforge.net/mailarchive/message.php?msg_id=11033442
Hope this helps,
JDH
From: John H. <jdh...@ac...> - 2005年03月18日 21:21:59
>>>>> "Fernando" == Fernando Perez <Fer...@co...> writes:
 Fernando> Hi all, I wonder how I can get, in an easy way, the
 Fernando> number of a figure returned by a call to figure(None).
 Fernando> The nasty way is:
 Fernando> allnums = [f.num for f in
 Fernando> _pylab_helpers.Gcf.get_all_fig_managers()] if allnums:
 Fernando> num = max(allnums) + 1 else: num = 1
 Fernando> but this seems horrible for everyday, user-level code.
 Fernando> What I want to do is simply be able to make a call to:
 Fernando> ff=figure()
 Fernando> and then later make a series of plots which go to that
 Fernando> figure:
 Fernando> myplotfunc(fignum=ff.num) myplotfunc2(fignum=ff.num) ...
What if we just attach the num attribute in the pylab figure function
 figManager.canvas.figure.num = num
 return figManager.canvas.figure
From: Fernando P. <Fer...@co...> - 2005年03月18日 19:59:48
Hi all,
I wonder how I can get, in an easy way, the number of a figure returned by a 
call to figure(None). The nasty way is:
 allnums = [f.num for f in _pylab_helpers.Gcf.get_all_fig_managers()]
 if allnums:
 num = max(allnums) + 1
 else:
 num = 1
but this seems horrible for everyday, user-level code. What I want to do is 
simply be able to make a call to:
ff=figure()
and then later make a series of plots which go to that figure:
myplotfunc(fignum=ff.num)
myplotfunc2(fignum=ff.num)
...
I need to overlay a set of plots on the same figures, and I don't want to 
manage manually the figure numbering. I'm comparing results across runs of a 
script, so the automatic figure(None) number increase is perfect. But I need 
a way to get a hold of those numbers somehow, and I don't see how. I looked 
at the attributes in the returned figure object, and I couldn't find the 
number anywhere (I think it's hidden higher up in the figure manager object).
An alternate (perhaps more 'pythonic'?) solution would be to allow figure() to 
take figure objects (not just numbers) as arguments. In this case, it would 
simply be a matter of saying:
ff=figure()
and then later make a series of plots which go to that figure:
myplotfunc(fig=ff)
myplotfunc2(fig=ff)
At any rate, either an integer-based or an object-based solution would work 
for me, so I'll be grateful for any pointers.
best,
f

Showing results of 214

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