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



Showing results of 33

1 2 > >> (Page 1 of 2)
From: John H. <jdh...@ac...> - 2003年12月29日 15:48:43
>>>>> "Eugene" == Eugene A Suchkov <Cit...@in...> writes:
 Eugene> 1) I can't make 2 plots using WX-backend sequentially
Do you need to use matplotlib interactively from the prompt, or do you
simply need to make 2 figures?
The latter is easy
 import matplotlib
 matplotlib.use('WX')
 from matplotlib.matlab import *
 figure(1)
 plot([1,2,3,4])
 figure(2)
 plot([1,4,9,16])
 show()
For interactive mode, as suggested earlier, we're still ironing out
the bugs regarding interactivity and WX.
Thanks!
John Hunter
From: John H. <jdh...@ac...> - 2003年12月29日 15:45:41
>>>>> "Eugene" == Eugene A Suchkov <Cit...@in...> writes:
 Eugene> When I'm performing smth like:
 Eugene> tl=get_xticklabels(...) for l in tl: print get_text(l)
 Eugene> I'm wondering why tl is a correct list, but with empty
 Eugene> text :(
This is related to the first problem you are having. When you are not
running matplotlib in interactive mode, nothing on the plotting side
is done until you call 'show()'. The reason for this is that the
backend doesn't have access to the gtk primitives until the window is
realized.
If you start your script with
 >>> import matplotlib
 >>> from matplotlib.matlab import *
 >>> from matplotlib.backends.backend_gtk import ShowOn
 >>> ShowOn().set(1) # turning on interactive mode
and turn on interactive mode, then you can, for example, print the
labels before calling show, as in the script below.
Note however, whether or not you are in interactive mode, you will be
able to control the text properties, as in 
 ax = subplot(111)
 ax.plot([1,2,3])
 tl = ax.get_ticklabels()
 set(tl, 'color', 'r')
You aren't the first one to be confused about interactive mode
vis-a-vis the various backends. It's not a trivial issue since both
the GTK and WX backend have event loops that they go into, but it's a
high priority since it's causing trouble for several people.
Hopefully by the next minor release we'll have it worked out.....
import matplotlib
from matplotlib.matlab import *
from matplotlib.backends.backend_gtk import ShowOn
ShowOn().set(1) # turning on interactive mode
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
ax = subplot(111)
ax.plot(t,s)
tl = ax.get_xticklabels()
for l in tl:
 print l.get_text()
show()
From: John H. <jdh...@ac...> - 2003年12月29日 15:30:34
>>>>> "Todd" == Todd G Gardner <pi...@ea...> writes:
 Todd> Hello all, Please pardon my ignorance as I am fairly new to
 Todd> matplotlib.
 Todd> I have 1000 sets of (x,y) data. I would like to cycle
 Todd> through this data by graphing set 1 then 2 then ... 1000.
 Todd> How can I refresh a plot without closing and reopening that
 Todd> plot?
Pekko Piirola <pek...@he...> sent me an example some time
ago that cycles through a data set. Currently this example only works
in the GTK backend, but we're actively working on getting a unified
GUI interface to allow for this kind of thing. You may also want to
take a look at examples/system_monitor.py and examples/dynamic_demo.py
which show how to dynamically update a plot.
#!/usr/bin/env python2.3
import matplotlib.matlab
import gtk
import Numeric
fig = matplotlib.matlab.figure(1)
ind = Numeric.arange(60)
x_tmp=[]
for i in range(100):
 x_tmp.append(Numeric.sin((ind+i)*Numeric.pi/15.0))
X=Numeric.array(x_tmp)
lines = matplotlib.matlab.plot(X[:,0],'o')
def updatefig(*args):
 updatefig.count += 1
 if updatefig.count>59: updatefig.count=0
 lines[0].set_data(ind,X[:,updatefig.count])
 fig.draw()
 return gtk.TRUE
updatefig.count=-1
gtk.timeout_add(200,updatefig)
matplotlib.matlab.show()
From: Todd G. G. <pi...@ea...> - 2003年12月29日 07:02:35
Hello all,
Please pardon my ignorance as I am fairly new to matplotlib.
I have 1000 sets of (x,y) data. I would like to cycle through this data by
graphing set 1 then 2 then ... 1000.
How can I refresh a plot without closing and reopening that plot?
Any pointer would be greatly appreciated.
Todd
From: Jeremy O'D. <je...@o-...> - 2003年12月28日 22:45:12
Hi Eugene,
On Sunday 28 December 2003 7:34 am, you wrote:
>
> I's really useful feature, e.g.:
>
> I have a WX program. It has some buttons, checkboxes, radiobuttons, to
> combine the options (detrending, plotting autocorrelation etc), and I
> can perform this options for any file with data. Now the user should
> quit this program to plot anothe graph... I's really tiring :(
Looking at this description, I wonder if it might be better for you to embed a 
figure in your application. You will then be able to build up the figure as 
you want it and hit the 'save' button, then maybe continue with changes, or 
clear the data in the chart.
The example 'embedding_in_wx.py' shows how to embed a Matplotlib chart in a 
wxFrame (and it works just as well if the PlotFigure class is derived from 
wxPanel, which is what you would probably do in a larger program than the 
short example).
The plotted data itself is stored in a FigureWx instance. This needs to be 
associated with a FigureManager and Toolbar instance if you want to be able 
to pan, zoom and save plot images.
In the example, the plotting is done in a single function, plot_data(). 
However, it is easy to add event handling functions which act on the Figure, 
e.g., if data is held in self.data_x and self.data_y, and the axis instance 
is self.axis:
(in __init__() for PlotFigure):
 EVT_BUTTON(self, ID_REGRESSION, self.onRegressionButton)
...
and new function:
def onRegressionButton(self, evt):
 reg_x, reg_y = PerformRegression(self.data_x, self.data_y)
 self.axis.plot(reg_x, reg_y)
 self.toolbar.update()
 self.fig.draw() 
Hope this helps. I'll make the changes for show() anyway - it is important to 
John and I that all backends are as close to identical as possible, and you 
have clearly identified the bug for me. Good luck, and thanks for the 
feedback.
Regards
Jeremy
From: Jeremy O'D. <je...@o-...> - 2003年12月27日 13:18:17
Hi Eugene,
I've had a quick look into the problem for you, and I can't give an immediate 
solution, but I'll try to get a fix in the next few days.
I can say that in the original design, the intention was that show() would be 
the last line of any script. I know that John (author of virtually everything 
in Matplotlib except backend_wx) has recently made some changes to allow 
show() to be called more than once.
Unfortunately, the code needed to do thisis quite specific to each GUI 
library, and I cannot simply port what has been done for GTK (I've just tried 
something very close to the GTK implementation, and it doesn't work).
A few questions for John Hunter: 
I think I need to do something like the following:
- show() must now instantiate any figures already defined and enter the the 
main event loop. ShowOn needs to keep track of this.
- I need to keep track of the number of figures instantiated. I assume that 
Gcf.destroy() does this.
- I need to ensure that I do not exit when the last figure is destroyed, and 
therefore need to manage that I may need to create a new figure manager if 
there is none.
Have I missed anything?
Regards
Jeremy
Eugene A. Suchkov writes:
>
> Hi all!
> 
> There are some bug's I've found in two days I got started with echotag.
> 
> 1) I can't make 2 plots using WX-backend sequentially
> 
> For example:
> 
> ---CODE---
> 
> import matplotlib
> matplotlib.use('WX')
> from matplotlib.matlab import *
> plot([1,2,3,4])
> show()
> plot([1,4,9,16])
> show()
> 
> --END CODE--
> 
> Well, everything is OK, while building 1st graph, but then an error
> occurs:
> 
> --OUTPUT--
> 
> Traceback (most recent call last):
> File "plot.py", line 7, in ?
> plot([1,4,9,16])
> File "/usr/lib/python2.2/site-packages/matplotlib/matlab.py", line
> 723, in plot draw_if_interactive()
> File
> "/usr/lib/python2.2/site-packages/matplotlib/backends/backend_wx.py",
> line 986, in draw_if_interactive current_fig =
> Gcf().get_current_figwin().figure AttributeError: 'Gcf' object has no
> attribute 'get_current_figwin'
> 
> --END OUTPUT--
> It was tested on Linux and Windows. Versions 0.40 and 0.32
> 
> When I'm using GTK everything is OK with both graphs, but using WX is
> critical :(
From: Eugene A. S. <Cit...@in...> - 2003年12月26日 09:45:14
Hi all!
There are some bug's I've found in two days I got started with echotag.
1) I can't make 2 plots using WX-backend sequentially
For example:
---CODE---
import matplotlib
matplotlib.use('WX')
from matplotlib.matlab import *
plot([1,2,3,4])
show()
plot([1,4,9,16])
show()
--END CODE--
Well, everything is OK, while building 1st graph, but then an error
occurs:
--OUTPUT--
Traceback (most recent call last):
 File "plot.py", line 7, in ?
 plot([1,4,9,16])
 File "/usr/lib/python2.2/site-packages/matplotlib/matlab.py", line
723, in plot draw_if_interactive()
 File
"/usr/lib/python2.2/site-packages/matplotlib/backends/backend_wx.py",
line 986, in draw_if_interactive current_fig =
Gcf().get_current_figwin().figure AttributeError: 'Gcf' object has no
attribute 'get_current_figwin'
--END OUTPUT--
It was tested on Linux and Windows. Versions 0.40 and 0.32
When I'm using GTK everything is OK with both graphs, but using WX is
critical :(
2) matplotlib-0.40:
When I'm performing smth like: 
tl=get_xticklabels(...)
for l in tl:
	print get_text(l)
I'm wondering why tl is a correct list, but with empty text :(
Version 0.32 is OK
P.S. 
Sorry for my bad english
-- 
Best regards
Eugene A. Suchkov
***************************
* ICQ:177787156 *
* JID: cit...@ja... *
***************************
 
From: Charles R. T. <cha...@in...> - 2003年12月18日 17:20:00
JH> 2) The http://www.forkosh.com/mimetex.html license is GPL, which in
JH> my understanding is not really compatible with the PSF license.
You can always write them and ask for another license.
	-crt
From: John H. <jdh...@ac...> - 2003年12月18日 13:23:53
>>>>> "Flavio" == Flavio C Coelho <fcc...@fi...> writes:
 Flavio> Hi John, I know that you are probably already overwhelmed
 Flavio> by maintenance and developmente of this great package, but
 Flavio> I came across a post on the mod_python list in which a
 Flavio> person was inquiring about the existance of a plotting
 Flavio> package for mod_python since mod_PHP and mod_Perl have
 Flavio> theirs. I thought that this could be a great thing to add
 Flavio> to matplotlib: a mod_python backend. It would be awesome
 Flavio> if we could have scientific python applets that could
 Flavio> generate full graphical output on the web.
 Flavio> It shouldn't be too hard to do since it could use any of
 Flavio> the existing backends and just export the resulting figure
 Flavio> to mod_python to embed in a web page...
 Flavio> what do you think?
I am currently using matplotlib as a plotting backend for a web
server. I'm working with a PHP developer who is writing the html, and
he calls an XML-RPC python server with the parameters for the plot.
The XML-RPC server does some number crunching, generates a plot with
matplotlib, saves it in a tmp dir, and passes the image filename back
to the PHP client. I'm using the GTK backend running in an Xvfb.
I don't know much about apache, or what is involved in making
something for mod_python. You wouldn't really need a 'mod_python
backend' would you? My guess is that you would just need to import
matplotlib into your mod_python python code, for example using the GD
backend, and plot away. Or is there something more to it? 
Do you know if you can use mod_python and mod_php together? Can
functions written in one mod_* language communicate with functions
written in another. My guess is not.... It would be great if I could
use mod_python and my front end person uses mod_php, and we could
communicate within apache w/o going through the XML-RPC server.
John Hunter 
From: John H. <jdh...@ac...> - 2003年12月17日 03:39:33
>>>>> "Flavio" == Flavio C Coelho <fcc...@fi...> writes:
 Flavio> Hi John, I followed a discussion on the list a while ago,
 Flavio> where some suggestions were made as to how math
 Flavio> typesetting could be added to th plots. I don't know if
 Flavio> you have already made up your mind about how this should
 Flavio> be done in matplotlib, but I recently came across a good
 Flavio> and very light solution for typesetting equations from
 Flavio> latex code without having to use tex/latex in any way.
 Flavio> Its a small ansi C program called mimetex that generates a
 Flavio> bitmap directly from latex code. I have been using it as a
 Flavio> cgi for typesetting equations from latex code embedded in
 Flavio> html, and I am very happy with it. Take a look at its
 Flavio> website: http://www.forkosh.com/mimetex.html
Hi Flavio,
Thanks for the pointer - I'll definitely keep it in mind. I have two
reservations
 1) bitmap output might be hard to support across the various
 backends, eg, postscript. This limitation is probably not fatal,
 though, since postscript can instead use native TeX output. I've
 been meaning to take a closer look at pyx -
 http://pyx.sourceforge.net - which has very nice postscript / TeX
 integration, to see how they pull it off. Even if TeX / LaTeX
 were only supported in one matplotlib backend that would be better
 than none.
 2) The http://www.forkosh.com/mimetex.html license is GPL, which in
 my understanding is not really compatible with the PSF license.
 Ie, the python license (like the BSD, MIT and related licenses)
 permits more or less *any* non-warranted use of the code,
 including proprietary / closed source. matplotlib is released
 under the PSF license. GPL requires that code that uses it to
 also be open source / free software. I have not thought about
 this deeply, or consulted a lawyer, so this is really just my
 impression after a somewhat cursory investigation, but it's a
 consideration. Licensing gurus please weigh in here....
But these considerations aside, it's a very good suggestion. At the
least, it would be nice to have it as a backend dependent optional
addon. I've wanted to have the ability to plot an image in an axes
for some time (something like matlab's imshow). If this functionality
existed, it would be relatively easy to plug the mimetex bitmaps into
it. 
JDH
From: Sajec, M. T. <ms...@tq...> - 2003年12月17日 00:00:07
Is it possible to use the wx backend interactively with a wx based shell?
And If so, is there any documentation on how to do so?
Thnx,
-Mike
From: Christopher F. <ch...@fo...> - 2003年12月16日 21:33:07
Whenever I run a program that imports matplotlib, it requests pythonw 
rather than python. Here's the message:
This program needs access to the screen. Please run with
'pythonw', not 'python', and only when you are logged in on the main 
display
of your Mac.
Is there any way of getting around this? In particular, when I am 
running python remotely on the terminal, it will not let me use 
matplotlib since access to the screen is required. However, I would 
like to be able to generate plots to file (remotely) without ever 
showing them on the screen. Is there something I need to set in order 
to satisfy this?
Thanks,
--
Christopher J. Fonnesbeck ( c h r i s @ f o n n e s b e c k . o r g )
Georgia Cooperative Fish & Wildlife Research Unit, University of Georgia
From: John H. <jdh...@ac...> - 2003年12月16日 13:48:37
>>>>> "Flavio" == Flavio C Coelho <fcc...@fi...> writes:
 Flavio> John, is there a way, in matplotlib, to emulate the
 Flavio> behavior of the matlab "hold" comand to plot multiple
 Flavio> datasets on a single figure?
The default behavior in matplotlib is 'hold on'.
Eg, 
 plot(x1, y1)
 plot(x2, y2)
Both plot to the same figure.
This is one way in which matplotlib differs from matlab.
From: K.KISHIMOTO <ko...@us...> - 2003年12月16日 12:48:07
Thanks for your quick reply.
On 2003年12月16日, at 20:47 Japan, John Hunter wrote:
> Is this what you mean?
More precisely, what I mean is like the top-left plot in 
http://www.slac.stanford.edu/grp/ek/hippodraw/canvaswindow.png
If I understand bar() (then hist()) functionalities correctly, it may 
be unable to create such a plot currently without using plot().
from matplotlib.matlab import *
bins = [0, 1, 2, 3]
vals = [3, 4, 5]
x = [bins[0]]
y = [0]
vals.append(0)
for i in range(len(bins) - 1):
 x.append(bins[i])
 y.append(vals[i])
 x.append(bins[i + 1])
 y.append(vals[i])
 x.append(bins[i + 1])
 y.append(vals[i + 1])
plot(x, y)
show()
From: John H. <jdh...@ac...> - 2003年12月16日 11:55:06
>>>>> "K" == K KISHIMOTO <ko...@us...> writes:
 K> If possible, I think it is nice for matplotlib to be able to
 K> plot histograms by not only bars but also lines. My meaning of
 K> "bar histogram plotting" is like the bottom-left plot in
 K> http://jas.freehep.org/images/screenshots/gui2.gif and "line
 K> histogram plotting" is like the others. There are two reasons.
If I understand you correctly, and from looking at the images you
linked to, all you need to do is set the edge and face properties of
the bars to the same color. The default edge color is black and the
default face color is blue, so if you want a solid histogram do
 from matplotlib.matlab import *
 mu, sigma = 100, 15
 x = mu + sigma*randn(10000)
 n, bins, patches = hist(x, 200, normed=1)
 set(patches, 'edgecolor', 'b')
 show()
Is this what you mean?
 K> Off course, the bar histogram plotting is more smart in one
 K> case, but in another case the line is better. In addition, the
 K> support of both bar and line histogram plotting will matplotlib
 K> to be able to have more plotting features that the colors of
 K> line and filled area can be specified separately by the user.
The axes function 'vlines' plots vertical lines. See the
example/vline_demo.py
Cheers,
John Hunter
From: K.KISHIMOTO <ko...@us...> - 2003年12月16日 08:36:09
Hi,
On 2003年12月15日, at 23:09 Japan, John Hunter wrote:
> OK, I'll give it some thought. Sounds reasonable enough. It doesn't
> break backwards compatibility, adds useful features, and is more
> consistent with bar.
Thank you so much!
If possible, I think it is nice for matplotlib to be able to plot 
histograms by not only bars but also lines.
My meaning of "bar histogram plotting" is like the bottom-left plot in 
http://jas.freehep.org/images/screenshots/gui2.gif and "line histogram 
plotting" is like the others.
There are two reasons.
(1) Because one bin width becomes a few pixcels, it is hard to see when 
the number of bins is about a few thousand in the bar histogram 
plotting mode.
(2) The color of all of the data filled area become the same by using 
bar and one can specify the line color separately. This brings smart 
view when multiple histograms are plotted like in 
http://root.cern.ch/root/html/examples/gif/hsum.gif
Off course, the bar histogram plotting is more smart in one case, but 
in another case the line is better.
In addition, the support of both bar and line histogram plotting will 
matplotlib to be able to have more plotting features that the colors of 
line and filled area can be specified separately by the user.
It seems that it is relatively not difficult to implement the feature 
by connecting points of [(x0, 0), (x0, y0), (x1, y0), (x1, y1), (x2, 
y1), (x2, y2), ...(and so on)] and will also not break backwards 
compatibility.
If possible, please give a consideration to this.
>>>>>> "K" == K KISHIMOTO <ko...@us...> writes:
>
> K> I am sorry that my last explanation was insufficient. The
> K> point is that I think it is inefficient to execute the
> K> following two lines in matplotlib.mlab.hist when I know the
> K> result of "n" already.
>
> Good point ...
>
> K> Another point is hist() does not support error bar plot (but
> K> bar() called from hist() does support.)
>
> Another good point....
>
> K> So, I propose again def hist(x, bins=10, noplot=0, normed=0,
> K> weights=None, errors=None , **kwargs): in matplotlib.matplab.
> K> I think if matplotlib supports this by default, it is very
> K> smart and usefull to many users when making histogram plots
> K> with matplotlib than letting hist() be mainly for the purpose
> K> of "calculating" histograms.
>
> OK, I'll give it some thought. Sounds reasonable enough. It doesn't
> break backwards compatibility, adds useful features, and is more
> consistent with bar.
>
> JDH
>
From: John H. <jdh...@ac...> - 2003年12月15日 22:42:53
>>>>> "Christopher" == Christopher Fonnesbeck <ch...@fo...> writes:
 Christopher> ... I'm not sure why I'd want to use gtk instead of
 Christopher> wx anyhow, given the choice.
One more option. If all you want is the batch generation of figures
offline with no display, you can use either the PS or GD backends. PS
only requires Numeric. gd, however, takes some energy to build.
But it works: I just built all the prereqs on OSX from source and it
worked perfectly.
You need
libjpeg - http://freshmeat.net/redir/libjpeg/5665/url_tgz/jpegsrc.v6b.tar.gz
 ./configure
 sudo make
 sudo cp libjpeg.a /usr/local/lib/
 sudo cp *.h /usr/local/include/
libpng - http://umn.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.5.tar.gz
 cp scripts/makefile.macosx Makefile
 sudo make install
You then need to follow the build instructions for gd, gdmodule and
dependencies at
http://matplotlib.sourceforge.net/backends.html#GD
Here's an example script ....
import matplotlib
matplotlib.use('GD')
from matplotlib.matlab import *
t = arange(0.0, 3.0, 0.01)
for i in range(1,10):
 figure(1)
 s = sin(2*pi*i*t)
 plot(t,s)
 savefig('plot%02d' % i)
 close(1)
I put all this here mainly for archival purposes in case someone wants
to use matplotlib / OSX / gdmodule. We'll get the wx thing figured
out too ....
JDH
From: John H. <jdh...@ac...> - 2003年12月15日 21:40:47
>>>>> "Christopher" == Christopher Fonnesbeck <ch...@fo...> writes:
 Christopher> ... I'm not sure why I'd want to use gtk instead of
 Christopher> wx anyhow, given the choice.
No compelling reason. The GTK backend was the first and probably the
most stable for that reason. This is the first release with the wx
backend, so there are likely some bugs lurking that will have to be
found and stamped out.
 Christopher> I'm trying to keep my plotting in a separate module
 Christopher> from everything else, so that I don't have to make
 Christopher> changes all over the place when I change my plotting
 Christopher> code. For example, plot_histogram() can be called
 Christopher> from any other module without knowing how the plot is
 Christopher> implemented. If I have to call show() from each
 Christopher> module that uses the plotting module, it will start
 Christopher> to get messy. Outside of the Plot module, the rest of
 Christopher> my code shouldn't have to know anything about
 Christopher> matplotlib. So, I'd like to be able to gererate and
 Christopher> save a plot, then move on to the next piece of
 Christopher> code. I'm trying to use your package in place of
 Christopher> scipy, which is what I have been using to generate
 Christopher> plots up until now; hopefully I can make it work.
Would you like this to run 'offline' so that no windows pop up as you
create the figures, or is it enough simply that you can create them
one at a time in batch mode with the plot functionality encapsulated?
I just installed wxpython and matplotlib on OS X, so I'll have a
chance to delve into this issue a bit....
John Hunter
From: Christopher F. <ch...@fo...> - 2003年12月15日 21:13:55
On Dec 15, 2003, at 3:29 PM, John Hunter wrote:
>
>
> Christopher> I'm trying to use matplotlib on OSX (so with WX
> Christopher> rather than gtk) in conjunction with my own code that
>
> Not necessarily. pygtk, gtk-2, etc... have been packaged for fink.
> I'm going to try and install them on my powerbook when I get a few
> minutes.
I like to avoid fink unless I absolutely have to use it -- it ends up 
installing a whole bunch of packages that I already have elsewhere on 
my machine, thereby creating the need to maintain multiple 
installations of the same package.
... I'm not sure why I'd want to use gtk instead of wx anyhow, given 
the choice.
>
> show must be the last line of your script. Is it possible to do all
> the figures in the loop and then call show? If your number of figures
> is very large, you could run into memory problems this way. There is
> a work-around, but if you can do it all in memory that is the easiest
> solution
>
> for i in range(1,10):
> figure(i)
> # do plot i
> savefig('plot%d'%i)
> show()
>
> This is an area that I am actively working on (in fact I was working
> on it when you emailed!) so if this isn't a viable solution for you
> let me know. I'm implementing some features to make it easier to use
> matplotlib in with xvfb (virtual x) so you can produce plots in wx or
> gtk without launching the GUI windows.
>
>
I'm trying to keep my plotting in a separate module from everything 
else, so that I don't have to make changes all over the place when I 
change my plotting code. For example, plot_histogram() can be called 
from any other module without knowing how the plot is implemented. If I 
have to call show() from each module that uses the plotting module, it 
will start to get messy. Outside of the Plot module, the rest of my 
code shouldn't have to know anything about matplotlib. So, I'd like to 
be able to gererate and save a plot, then move on to the next piece of 
code. I'm trying to use your package in place of scipy, which is what I 
have been using to generate plots up until now; hopefully I can make it 
work.
--
Christopher J. Fonnesbeck ( c h r i s @ f o n n e s b e c k . o r g )
Georgia Cooperative Fish & Wildlife Research Unit, University of Georgia
From: John H. <jdh...@ac...> - 2003年12月15日 21:07:06
>>>>> "Christopher" == Christopher Fonnesbeck <ch...@fo...> writes:
 Christopher> code for some reason, but instead hangs. When I try
 Christopher> and close the plot manually, it terminates the python
 Christopher> code. How can I get matplotlib to produce a new plot
 Christopher> each time it is called, moving on after each plot is
 Christopher> produced, displayed and saved to file. Here is a
 Christopher> sample function from my code:
For the GTK backend, there is another solution. The call to 
ShowOn().set(1) tells matplotlib to execute the commands as they are
issued, which was originally designed for people using matplotlib
from the python shell but also applies to your case, where you want to
generate a bunch of figures one at a time
import matplotlib
matplotlib.use('GTK')
from matplotlib.matlab import *
from matplotlib.backends.backend_gtk import ShowOn
ShowOn().set(1) 
t = arange(0.0, 3.0, 0.01)
for i in range(1,10):
 figure(1)
 s = sin(2*pi*i*t)
 plot(t,s)
 savefig('plot%02d' % i)
 close(1)
*Note there is no call to show at the end*
The same trick *does not* currently work with the WX backend, though
perhaps Jeremy can take a look at it and determine why not. Somehow
the call the ShowOn().set(1) seems to screw it up.
We'll look into it...
JDH
From: John H. <jdh...@ac...> - 2003年12月15日 20:37:27
>>>>> "Christopher" == Christopher Fonnesbeck <ch...@fo...> writes:
 Christopher> First off, I want to congratulate the authors of
 Christopher> matplotlib for making a great package. This is the
 Christopher> python plotting library I've been waiting for.
Thanks!
 Christopher> I'm trying to use matplotlib on OSX (so with WX
 Christopher> rather than gtk) in conjunction with my own code that
Not necessarily. pygtk, gtk-2, etc... have been packaged for fink.
I'm going to try and install them on my powerbook when I get a few
minutes.
 Christopher> produces Markov chain Monte Carlo simulations. At the
 Christopher> end of the simulation, I try to plot traces and
 Christopher> histograms of all of the sampled values. However,
 Christopher> matplotlib gets stuck on the first plot. After
 Christopher> calling show(), it does not move to the next line of
 Christopher> code for some reason, but instead hangs. When I try
 Christopher> and close the plot manually, it terminates the python
 Christopher> code. How can I get matplotlib to produce a new plot
 Christopher> each time it is called, moving on after each plot is
 Christopher> produced, displayed and saved to file. Here is a
 Christopher> sample function from my code:
show must be the last line of your script. Is it possible to do all
the figures in the loop and then call show? If your number of figures
is very large, you could run into memory problems this way. There is
a work-around, but if you can do it all in memory that is the easiest
solution
for i in range(1,10):
 figure(i)
 # do plot i
 savefig('plot%d'%i)
show()
This is an area that I am actively working on (in fact I was working
on it when you emailed!) so if this isn't a viable solution for you
let me know. I'm implementing some features to make it easier to use
matplotlib in with xvfb (virtual x) so you can produce plots in wx or
gtk without launching the GUI windows.
JDH
From: Christopher F. <ch...@fo...> - 2003年12月15日 20:22:48
First off, I want to congratulate the authors of matplotlib for making 
a great package. This is the python plotting library I've been waiting 
for.
I'm trying to use matplotlib on OSX (so with WX rather than gtk) in 
conjunction with my own code that produces Markov chain Monte Carlo 
simulations. At the end of the simulation, I try to plot traces and 
histograms of all of the sampled values. However, matplotlib gets stuck 
on the first plot. After calling show(), it does not move to the next 
line of code for some reason, but instead hangs. When I try and close 
the plot manually, it terminates the python code. How can I get 
matplotlib to produce a new plot each time it is called, moving on 
after each plot is produced, displayed and saved to file. Here is a 
sample function from my code:
def 
plot_histogram(data,name,nbins=None,xlab='Value',ylab='Frequency',suffix 
=''):
	'Internal histogram specification for handling nested arrays'
	
	'If there is only one data array, go ahead and plot it ... '
	if len(shape(data))==1:
		print 'Generating histogram of',name
		try:
			figure(1)
			nbins = min(nbins or 10,len(unique(data)))
			'Generate histogram'
			hist(data,nbins)
			'Plot options'
			xlabel(name)
			ylabel("Frequency")
			show()
			'Save to file'
			savefig("%s%s.png" % (name,suffix))
			close(1)
		except OverflowError:
			print '... cannot generate histogram'
	else:
		'... otherwise, plot recursively'
		tdata = swapaxes(data,0,1)
		for i in range(len(tdata)):
Thanks for any advice,
C.
--
Christopher J. Fonnesbeck ( c h r i s @ f o n n e s b e c k . o r g )
Georgia Cooperative Fish & Wildlife Research Unit, University of Georgia
From: John H. <jdh...@ac...> - 2003年12月15日 16:04:58
matplotlib is a pure python 2D plotting library with a matlab syntax
which produces publication quality figures using in a variety of
hardcopy formats (PNG, JPG, TIFF, PS) and interactive GUI environments
(WX, GTK) across platforms. matplotlib can be used in python scripts,
interactively from the python shell (ala matlab or mathematica), in
web application servers generating dynamic charts, or embedded in GTK
or WX applications.
 http://matplotlib.sourceforge.net
What's new
WX python backend
 Jeremy O'Donoghue has done an amazing job implementing the backend
 for wxpython, with all the features such as interactive navigation
 that are supported in the GTk backend. matplotlib should not be
 available with a GUI anywhere wxpython, Numeric and python work,
 including linux and friends, win32, and Mac OS X. See
 http://matplotlib.sourceforge.net/matplotlib.backends.backend_wx.html
 for a summary of known issues.
Pseudo color plots
 The pcolor command generates pseudo color plots. See
 http://matplotlib.sourceforge.net/screenshots.html#pcolor_demo and
 http://matplotlib.sourceforge.net/screenshots.html#mri_with_eeg for
 screenshots and example code
New time-series plotting functions
 
 * psd - plots the power spectral density of a time series
 * csd - plots the cross spectral density of two time series
 * cohere - plots the coherence
 See the examples dir in the src distro: psd_demo.py and csd_demo.py
Substantially improved layout
 The transform architecture was refactored, allowing much more
 precise layout. Lines, patches, text, etc... can now be placed and
 scaled in arbitrary units, relative axes units, or physical size.
 Applicaiton programmers who want to create lines, patches and text
 directly using the API should read the transform module docs for
 more info. See the text help for an example of how to specify text
 locations in axes coords (0,0 is lower left and 1,1 is upper right)
Expanded legend capabilities
 The legend class is improved, with a more sophisticated layout
 engine and the ability to accept lines and rectangle patches as an
 optional first argument to specify which lines/patches make up the
 legend. There are also additional legend placement locations, like
 'upper center'. See
 http://matplotlib.sourceforge.net/screenshots.html#legend_demo
Expanded errorbar capabilities
 Gary Ruben contributed some code to support x and y errorbars,
 either symmetrix or asymettric, in one enhanced function 'errorbar'.
 See the errorbar_demo.py for examples of all the wild and wonderful
 errorbar styles. Bar charts can now also display errorbars; see
 http://matplotlib.sourceforge.net/screenshots.html#barchart_demo
Figure size and DPI controllable from matlab interface
 The figure command now takes optional args figsize and dpi to set
 the figure size and DPI in the matlab interface. This change
 involved some changes in the way default sizes and resolutions were
 handled among the various backends, with the effect that figures
 generated by existing scripts may appear different, eg, in the
 relative size of text to the figure elements. The advantage is that
 the current implementation does a better job of computing true sizes
 with increased fidelity between backends. Apologies for any
 inconveniences!
API changes
 There have been some minor changes to the API for those using
 matplotlib embedded in GTK applications. 
 * If you instantiate an Axes of Subplot intace, the first arg to
 __init__ must be the figure that contains it.
 * If you instantiate any artists, eg, Line2D, Rectangle, or
 AxisTextGTk, you must initialize them with their dpi, bbox, and
 transforms. See the help for the transforms modules and the
 examples logo.py and mri_with_eeg.py, where the objects are
 explicity created using the new API.
 * The only change to the matlab interface is in the signature of the
 errorbar func, which breaks matlab compatibility for the enhanced
 ability to do x and y errorbars.
 * See matplotlib.axes.py for a complete list of API changes
John Hunter
From: John H. <jdh...@ac...> - 2003年12月15日 14:16:56
>>>>> "K" == K KISHIMOTO <ko...@us...> writes:
 K> I am sorry that my last explanation was insufficient. The
 K> point is that I think it is inefficient to execute the
 K> following two lines in matplotlib.mlab.hist when I know the
 K> result of "n" already.
Good point ...
 K> Another point is hist() does not support error bar plot (but
 K> bar() called from hist() does support.)
Another good point....
 K> So, I propose again def hist(x, bins=10, noplot=0, normed=0,
 K> weights=None, errors=None , **kwargs): in matplotlib.matplab.
 K> I think if matplotlib supports this by default, it is very
 K> smart and usefull to many users when making histogram plots
 K> with matplotlib than letting hist() be mainly for the purpose
 K> of "calculating" histograms.
OK, I'll give it some thought. Sounds reasonable enough. It doesn't
break backwards compatibility, adds useful features, and is more
consistent with bar.
JDH
From: K. K. <ko...@us...> - 2003年12月15日 13:38:29
Thank you for your reply.
> def func1(x=None):
> if x is None: x = []
> #blah blah
The indication is right.
I should have done so. Thank you.
> This seems like the kind of thing that would best be done in your user
> library. Eg, if you make a module mymatplotlib.py, you can defined
> your own hist. In that file, just import matplotlib.matlab and call
> matplotlib.matlab.hist within it. In fact, matplotlib.matlab.hist
> calls matplotlib.mlab.hist.
I am sorry that my last explanation was insufficient.
The point is that I think it is inefficient to execute the following 
two lines in matplotlib.mlab.hist when I know the result of "n" already.
 >> n = searchsorted(sort(y), bins)
 >> n = diff(concatenate([n, [len(y)]]))
For the moment, I must insert extra code
 >> y = [1.0] * 1000
(and hist(y, [0.0, 2.0]) calculates n = [1000], then plot the data.)
This is very expensive.
Another point is hist() does not support error bar plot (but bar() 
called from hist() does support.)
So, I propose again
def hist(x, bins=10, noplot=0, normed=0, weights=None, errors=None , 
**kwargs):
in matplotlib.matplab.
I think if matplotlib supports this by default, it is very smart and 
usefull to many users when making histogram plots with matplotlib than 
letting hist() be mainly for the purpose of "calculating" histograms.
Example rough code.
------
def hist(x, bins=10, noplot=0, normed=0, weights=None, xerr=None, 
yerr=None, **kwargs):
 if noplot:
 if weights == None:
 return mlab.hist(x, bins, normed)
 else:
 return (weights, bins)
 else:
 try:
 if weights == None:
 ret = gca().hist(x, bins, normed)
 else:
 ret = gca().bar(bins, weights, xerr=xerr, yerr=yerr, 
**kwargs)
 except ValueError, msg:
 msg = raise_msg_to_str(msg)
 error_msg(msg)
 raise RuntimeError, msg
 draw_if_interactive()
 return ret
4 messages has been excluded from this view by a project administrator.

Showing results of 33

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