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

Showing results of 356

<< < 1 .. 3 4 5 6 7 .. 15 > >> (Page 5 of 15)
From: Darren D. <dar...@co...> - 2008年02月23日 17:09:59
On Saturday 23 February 2008 10:49:25 am John Hunter wrote:
> On Fri, Feb 22, 2008 at 11:04 PM, sa6113 <s.p...@gm...> wrote:
> > I could return the output object of the plot as image file , would you
> > please tell me how I have to convert image to QImage in order to use it
> > in my GUI ?
>
> I could, but this is a very poor way to do it. First, you would not
> be able to interact with your figure (pan, zoom, etc). 2nd, you would
> be using qimage to rescale your plot with the embedded window size an
> this would be far inferior to having matplotlib draw into the
> requested size. The right way to use this is to follow the example of
> http://matplotlib.sourceforge.net/examples/embedding_in_qt4.py
Yes, please follow the example John pointed out. The qt4agg backend already 
provides a widget that you can embed in your program, an example is in 
embedding_in_qt4.py, it does the conversion to a QImage already, you dont 
need to reimplement it.
From: John H. <jd...@gm...> - 2008年02月23日 15:49:36
On Fri, Feb 22, 2008 at 11:04 PM, sa6113 <s.p...@gm...> wrote:
>
> I could return the output object of the plot as image file , would you please
> tell me how I have to convert image to QImage in order to use it in my GUI ?
I could, but this is a very poor way to do it. First, you would not
be able to interact with your figure (pan, zoom, etc). 2nd, you would
be using qimage to rescale your plot with the embedded window size an
this would be far inferior to having matplotlib draw into the
requested size. The right way to use this is to follow the example of
http://matplotlib.sourceforge.net/examples/embedding_in_qt4.py
JDH
From: Manuel M. <mm...@as...> - 2008年02月23日 12:33:51
Erik Tollerud wrote:
> I use the scatter(x,y) command to make scatter plots, but I noticed
> today (on the SVN version of mpl) that when I call legend() after
> giving scatter(x,y,label='somelabel') , the legend doesn't show the
> marker symbols - it only has a square patch colored in the color that
> was used for the scatter plot. Is this a bug, or intended behavior?
> (and is there a work-around to show the marker symbols in the legend?)
Hi Erik,
I would say it's neither a bug nor an intended bahavior. It's just not 
implemented -- so you might call it a misbehaviour ;-)
I too hope that this will be fixed/added, since it's an issue open some 
time now (I guess since scatter was implemented !?)
Manuel
Hello List,
I am using python-matplotlib version 0.87.7-0.3ubuntu1(feisty) and
having some problems with a script that uses it. I get this import error
and am not sure how to debug it further, any assistance would be greatly
appreciated.
Best regards, 
Paul marsh
---------------------------------------------------------------------
crank examples # pwd
/home/a_downloads/basemap-0.9.9.1/examples
crank examples # python simpletest.py
Traceback (most recent call last):
 File "simpletest.py", line 1, in <module>
 from matplotlib.toolkits.basemap import Basemap
 File
"/usr/lib/python2.5/site-packages/matplotlib/toolkits/basemap/__init__.py", line 1, in <module>
 from basemap import __doc__, __version__
 File
"/usr/lib/python2.5/site-packages/matplotlib/toolkits/basemap/basemap.py", line 20, in <module>
 from matplotlib.cbook import is_scalar, dedent
ImportError: cannot import name dedent
crank examples # python -c "from matplotlib.toolkits.basemap import
basemap_datadir;" 
Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File
"/usr/lib/python2.5/site-packages/matplotlib/toolkits/basemap/__init__.py", line 1, in <module>
 from basemap import __doc__, __version__
 File
"/usr/lib/python2.5/site-packages/matplotlib/toolkits/basemap/basemap.py", line 20, in <module>
 from matplotlib.cbook import is_scalar, dedent
ImportError: cannot import name dedent
crank examples # 
---------------------------------------------------------------------
From: sa6113 <s.p...@gm...> - 2008年02月23日 05:04:30
I could return the output object of the plot as image file , would you please
tell me how I have to convert image to QImage in order to use it in my GUI ?
sa6113 wrote:
> 
> How can I show my plot figure in the specific location or part of an
> application , I am using pylab.
> 
-- 
View this message in context: http://www.nabble.com/Showing-the-plot-in-the-specific-location-tp15545079p15648399.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Erik T. <eri...@gm...> - 2008年02月23日 03:02:00
I use the scatter(x,y) command to make scatter plots, but I noticed
today (on the SVN version of mpl) that when I call legend() after
giving scatter(x,y,label='somelabel') , the legend doesn't show the
marker symbols - it only has a square patch colored in the color that
was used for the scatter plot. Is this a bug, or intended behavior?
(and is there a work-around to show the marker symbols in the legend?)
From: Piotr Z. <zo...@ya...> - 2008年02月22日 21:31:32
 I guess it was a FAQ :) 
The correct way - after experimenting with imshow options - is to transpose the data and use origin='lower' option 
 
imshow(c.T,interpolation='nearest',origin='lower') 
 
Piotr 
 
 
----- Original Message ---- 
From: Piotr Zolnierczuk <zo...@ya...> 
To: mat...@li... 
Sent: Friday, February 22, 2008 2:31:08 PM 
Subject: [Matplotlib-users] imshow: axis not natural 
 
 Hi, 
it is probably a faq - but I could not find it anywhere. 
 
I would like to plot a 2D distribution (2D histogram) of some data using a 2D numpy.array that contains my data: c[ix,iy] 
When I plot it via imshow the x axis points downwards and the y axis point to the left. 
What I want is that the x-axis points to the left and the y axis points upwards. 
 
So I ended up writing a small script twodimshow (below) where I transpose data (x<->y) and also flip the sign of the y-axis 
 
Now: is there a better way of doing it? 
 
 
See also CERN Root C++ package (ftp://root.cern.ch/root/doc/3Histograms.pdf) and/or (SLAC HIPPO (http://www.slac.stanford.edu/grp/ek/hippodraw/) 
 
------------------- CODE BELOW --------------------------- 
import numpy 
from pylab import * 
 
def convertToImShow(data,copy=True): 
 '''Converts data so that imshow displays x,y as a normal 
 physicist expects ie x pointing left and y pointing up''' 
 data = numpy.array(data.T,copy=copy) 
 if data.ndim != 2: 
 raise TypeError,'data must be a two-dimensional matrix' 
 nx,ny = data.shape 
 for i in range(nx/2): 
 j= nx - i - 1 
 for k in range(ny): data[j,k],data[i,k]=data[i,k],data[j,k] 
 return data 
 
def twodimshow(data,extent=None,aspect=None): 
 r = convertToImShow(data) 
 if not aspect and extent: 
 if len(extent)>=4: 
 aspect = (extent[1] - extent[0])/float(extent[3] - extent[2]) 
 imshow(r,extent=extent,aspect=aspect,interpolation='nearest') 
 
if __name__ == "__main__": 
 c = zeros((4,4)) 
 for ix in range(4): 
 for iy in range(ix): 
 c[ix,iy]=ix+iy 
 
 figure() 
 subplot(221) 
 imshow(c ,interpolation='nearest') 
 title('Axis direction not natural') 
 xlabel('Y-Axis'); ylabel('X-Axis') 
 
 subplot(222) 
 imshow(c.T ,interpolation='nearest') 
 title('Not there yet') 
 xlabel('X-Axis'); ylabel('Y-Axis') 
 
 subplot(223) 
 twodimshow(c,extent=(0,4,0,4)) 
 title('That is what I want') 
 xlabel('X-Axis'); ylabel('Y-Axis') 
 show() 
 
 
 
 
 
 ____________________________________________________________________________________ 
Never miss a thing. Make Yahoo your home page. 
http://www.yahoo.com/r/hs 
 
------------------------------------------------------------------------- 
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ 
_______________________________________________ 
Matplotlib-users mailing list 
Mat...@li... 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
 
 
 ____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page. 
http://www.yahoo.com/r/hs
From: Piotr Z. <zo...@ya...> - 2008年02月22日 19:31:21
Hi,
it is probably a faq - but I could not find it anywhere.
I would like to plot a 2D distribution (2D histogram) of some data using a 2D numpy.array that contains my data: c[ix,iy] 
When I plot it via imshow the x axis points downwards and the y axis point to the left.
What I want is that the x-axis points to the left and the y axis points upwards.
So I ended up writing a small script twodimshow (below) where I transpose data (x<->y) and also flip the sign of the y-axis
Now: is there a better way of doing it? 
See also CERN Root C++ package (ftp://root.cern.ch/root/doc/3Histograms.pdf) and/or (SLAC HIPPO (http://www.slac.stanford.edu/grp/ek/hippodraw/)
------------------- CODE BELOW ---------------------------
import numpy
from pylab import *
def convertToImShow(data,copy=True):
 '''Converts data so that imshow displays x,y as a normal 
 physicist expects ie x pointing left and y pointing up'''
 data = numpy.array(data.T,copy=copy)
 if data.ndim != 2:
 raise TypeError,'data must be a two-dimensional matrix'
 nx,ny = data.shape
 for i in range(nx/2):
 j= nx - i - 1
 for k in range(ny): data[j,k],data[i,k]=data[i,k],data[j,k]
 return data
def twodimshow(data,extent=None,aspect=None):
 r = convertToImShow(data)
 if not aspect and extent:
 if len(extent)>=4:
 aspect = (extent[1] - extent[0])/float(extent[3] - extent[2])
 imshow(r,extent=extent,aspect=aspect,interpolation='nearest')
if __name__ == "__main__":
 c = zeros((4,4))
 for ix in range(4):
 for iy in range(ix):
 c[ix,iy]=ix+iy
 figure()
 subplot(221)
 imshow(c ,interpolation='nearest')
 title('Axis direction not natural')
 xlabel('Y-Axis'); ylabel('X-Axis')
 subplot(222)
 imshow(c.T ,interpolation='nearest')
 title('Not there yet')
 xlabel('X-Axis'); ylabel('Y-Axis')
 subplot(223)
 twodimshow(c,extent=(0,4,0,4))
 title('That is what I want')
 xlabel('X-Axis'); ylabel('Y-Axis')
 show()
 ____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page. 
http://www.yahoo.com/r/hs
From: Stephane R. <ste...@gm...> - 2008年02月22日 18:13:20
Hi,
what is the best way to use a Formatter for contour labels (clabel)
instead of using simple formatting ('%g')?
Should we derive a class from ContourLabeler and do things by hand?
It would be useful for example for showing labels from
power(10.,level) and you plot logarithmic values.
Thanks for the help.
-- 
Stephane Raynaud
From: Auré G. <aur...@ya...> - 2008年02月22日 15:08:47
Hi all,
In my latest post, I wanted to use the mpl.hist() function in a different way, i.e.:
x = datalist
bins= 100
hist(x,bins,normed=0) #returns a tupple (n,bins,patches)
Instead of ploting the number of counts n, I wanted to plot the relative percentage of counts, i.e. n/len(x). I can't really use the option normed=1 which returns n/(len(x)*dbin). In the axes.py module, this would simply mean adding an argument e.g. relpercent = 1. I added the code line to show how this could be done (in major cap). If this is useful, how could it be modified in the distribution ?
 def hist(self, x, bins=10, RELPERCENT = 1, normed=0, bottom=None,
 align='edge', orientation='vertical', width=None,
 log=False, **kwargs):
 """
 if not self._hold: self.cla()
 n, bins = npy.histogram(x, bins, range=None, normed=normed)
 IF NOT NORMED AND RELPERCENT: N = N/FLOAT(LEN(X))
 if width is None: width = 0.9*(bins[1]-bins[0])
 if orientation == 'horizontal':
 patches = self.barh(bins, n, height=width, left=bottom,
 align=align, log=log)
 elif orientation == 'vertical':
 patches = self.bar(bins, n, width=width, bottom=bottom,
 align=align, log=log)
 else:
 raise ValueError, 'invalid orientation: %s' % orientation
 for p in patches:
 p.update(kwargs)
 return n, bins, cbook.silent_list('Patch', patches)
 _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr 
From: John H. <jd...@gm...> - 2008年02月22日 14:15:41
On Fri, Feb 22, 2008 at 7:52 AM, Auré Gourrier
<aur...@ya...> wrote:
> Rather trivial... but instead of the plotting the counts n, I'd like to plot
> the realtive percentage counts, i.e. n/len(x). I can't really use the option
> normed = 1 which plots n/(len(x)*dbins). I guess the simplest way would be
> to simply change the yticklabels (by dividing them by len(x)). The thing is
> that I simply cannot find out how to do this...
>
> I tried using the axes.set_yticklabels() but doesn't work. I've also tried
> to find the child containing the label but couldn't find it (not in Axes,
> nor in YAxis etc...). I guess it must be a Text instance.
You can set your own custom tick formatter:
import matplotlib.ticker as ticker
N = len(x)
def fmt_percent(x, pos=None):
 return '%1.2f'%(float(x)/N)
ax.xaxis.set_major_formatter(ticker.FuncFormatter(fmt_percent)). See
http://matplotlib.sourceforge.net/examples/custom_ticker1.py for a
complete example.
JDH
From: Troels K. J. <tkj...@gm...> - 2008年02月22日 14:09:11
Thanks guys.
The env variable method doesn't work, but I can use the file in current dir
for now (will just symlink from the file i want).
Best Regards T.
On Fri, Feb 22, 2008 at 2:39 PM, Darren Dale <dar...@co...>
wrote:
> On Friday 22 February 2008 04:45:46 am Troels Kofoed Jacobsen wrote:
> > Hey everybody
> >
> > Is there at way to make matplotlib use a different matplotlibrc than the
> > one in $HOME/.matplotlib. This is because I want to be able to use
> > different settings for different plots, e.g one for publishable plots,
> and
> > one for daily plotting.
> >
> > Best regards
> >
> > Troels Kofoed Jacobsen
>
> Try saving a matplotlibrc file in your current working directory.
> Matplotlib
> looks there first.
>
> Darren
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Med Venlig Hilsen
Troels Kofoed Jacobsen
From: Antonio G. <ja...@ca...> - 2008年02月22日 13:59:51
Hi Aure,
You could try:
ax.set_yticklabels(ax.get_yticks()/len(x))
/Antonio
Auré Gourrier wrote:
> Hi all,
> 
> I'm plotting the histogram of a data set:
> 
> x = datalist
> bins= 100
> hist(x,bins,normed=0) #returns a tupple (n,bins,patches)
> 
> Rather trivial... but instead of the plotting the counts n, I'd like to 
> plot the realtive percentage counts, i.e. n/len(x). I can't really use 
> the option normed = 1 which plots n/(len(x)*dbins). I guess the simplest 
> way would be to simply change the yticklabels (by dividing them by 
> len(x)). The thing is that I simply cannot find out how to do this...
> 
> I tried using the axes.set_yticklabels() but doesn't work. I've also 
> tried to find the child containing the label but couldn't find it (not 
> in Axes, nor in YAxis etc...). I guess it must be a Text instance.
> 
> Can anyone give me a hint,
> 
> Cheers,
> 
> Aure
> 
> ------------------------------------------------------------------------
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails 
> <http://fr.rd.yahoo.com/mail/mail_taglines/trueswitch/SIG=11gshn0bu/**http%3A%2F%2Fwww.trueswitch.com%2Fyahoo-fr%2F> 
> vers Yahoo! Mail
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Auré G. <aur...@ya...> - 2008年02月22日 13:52:20
Hi all,
I'm plotting the histogram of a data set:
x = datalist
bins= 100
hist(x,bins,normed=0) #returns a tupple (n,bins,patches)
Rather trivial... but instead of the plotting the counts n, I'd like to plot the realtive percentage counts, i.e. n/len(x). I can't really use the option normed = 1 which plots n/(len(x)*dbins). I guess the simplest way would be to simply change the yticklabels (by dividing them by len(x)). The thing is that I simply cannot find out how to do this...
I tried using the axes.set_yticklabels() but doesn't work. I've also tried to find the child containing the label but couldn't find it (not in Axes, nor in YAxis etc...). I guess it must be a Text instance.
Can anyone give me a hint,
Cheers,
Aure
 _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr 
From: Darren D. <dar...@co...> - 2008年02月22日 13:38:54
On Friday 22 February 2008 04:45:46 am Troels Kofoed Jacobsen wrote:
> Hey everybody
>
> Is there at way to make matplotlib use a different matplotlibrc than the
> one in $HOME/.matplotlib. This is because I want to be able to use
> different settings for different plots, e.g one for publishable plots, and
> one for daily plotting.
>
> Best regards
>
> Troels Kofoed Jacobsen
Try saving a matplotlibrc file in your current working directory. Matplotlib 
looks there first.
Darren
From: Troels K. J. <tkj...@gm...> - 2008年02月22日 09:45:50
Hey everybody
Is there at way to make matplotlib use a different matplotlibrc than the one
in $HOME/.matplotlib. This is because I want to be able to use different
settings for different plots, e.g one for publishable plots, and one for
daily plotting.
Best regards
Troels Kofoed Jacobsen
From: Alan G I. <ai...@am...> - 2008年02月22日 04:01:29
On 2008年2月21日, John Hunter apparently wrote:
> you should not be using pylab, since you are embedding mpl in a 
> GTK GUI. 
Given the frequency of this question, maybe it would be 
a good idea on the main project page
<URL:http://matplotlib.sourceforge.net/>
to augment the text
 The plotting functions in the pylab interface have 
 a high degree of Matlab® compatibility.
to include a caveat:
 The plotting functions in the pylab interface have 
 a high degree of Matlab® compatibility. (These are
 suitable for plotting scripts but NOT for GUI 
 embeddding, which should use the matplotlib API.)
fwiw,
Alan Isaac
From: John H. <jd...@gm...> - 2008年02月22日 03:17:53
On Thu, Feb 21, 2008 at 2:33 AM, Wolfgang Kerzendorf
<wke...@go...> wrote:
> Dear all,
> I use the scisoft package on leopard 10.5.2 (it is a package that
> creates its own python framework and delivers astronomical tools). I
> have recompiled tcl tkk 8.4 and 8.5 (which in hindsight was probably
You probably have a few choices:
 * revert to a standard tk package to use the standard scisoft
compiled against it,
 * use a different backend for matplotlib -- eg download wxpython for
os x and then use the wxagg backend in matplotlib by setting the
backend variable in your rc file:
http://matplotlib.sf.net/matplotlibrc
 * compile matplotlib yourself on your platform against your new tk, see
 http://matplotlib.sourceforge.net/installing.html
 http://ipython.scipy.org/moin/Py4Science/InstallationOSX
 http://ipython.scipy.org/moin/MatplotlibOSXBuildNotes
Hope this helps,
JDH
From: John H. <jd...@gm...> - 2008年02月22日 03:08:55
On Thu, Feb 21, 2008 at 3:07 PM, Kevin Milner <km...@us...> wrote:
> Hi everyone,
>
> I am a developer on a PyGTK application for Earth Science research and
> education called SEATREE ( http://geosys.usc.edu/projects/seatree/wiki )
> and we are trying to integrate some pylab plots.
>
> I can successfully create and use a pylab frame/window inside of our GTK
> application using the following sequence (note that all of this is
> called AFTER the application has launched and the GTK main loop has
> started):
>
> -------------------------------------
> import math
> import pylab as p
> import matplotlib
> from matplotlib.backends.backend_gtk import FigureCanvasGTK,
> NavigationToolbar
> matplotlib.use('GTK')
For the "use" directive to be honored, it must be called before you
import pylab. If it is after, as in your example code, pylab will
respect the setting in your matplotlibrc file -- see
http://matplotlib.sf.net/matplotlibrc (this is likely why you are
getting unexplained references to tk code).
But you should not be using pylab, since you are embedding mpl in a
GTK GUI. Instead, you should be using the matplotlob API,
specifically the idioms for embedding mpl in gtk -- it takes a little
more work up front but it is the only acceptable way to use mpl in a
GTK app
http://matplotlib.sf.net/examples/embedding_in_gtk.py
http://matplotlib.sourceforge.net/examples/embedding_in_gtk2.py
See also the OO FAQ and the API tutorial for more insight into using
the API directly rather than the pylab interface
http://matplotlib.sf.net/faq.html#OO
http://matplotlib.sf.net/leftwich_tut.txt
JDH
JDH
From: Kevin M. <km...@us...> - 2008年02月21日 21:08:07
Hi everyone,
I am a developer on a PyGTK application for Earth Science research and 
education called SEATREE ( http://geosys.usc.edu/projects/seatree/wiki ) 
and we are trying to integrate some pylab plots.
I can successfully create and use a pylab frame/window inside of our GTK 
application using the following sequence (note that all of this is 
called AFTER the application has launched and the GTK main loop has 
started):
-------------------------------------
import math
import pylab as p
import matplotlib
from matplotlib.backends.backend_gtk import FigureCanvasGTK, 
NavigationToolbar 
matplotlib.use('GTK')
p.figure()
//set up the figure
//connect actions using p.connect('signal name', function)
p.show()
-------------------------------------
Then, once I'm done with the plot and it is closed, p.close() is called.
All of that works fine, and I actually like the blocking nature of the 
p.show() method (I know this probably isn't the best way since I already 
have a GTK main loop going). The problem arises when I try to display 
the plot again. If I just call the p.show() method for a 2nd time, it 
does not block execution of my function, and the plot shows up but is 
unresponsive with full CPU utilization. My main GTK window for the 
application is enabled and responsive during this time.
I then tried using the following code to show the window (either both 
times or just the 2nd time around):
-------------------------------------
for manager in Gcf.get_all_fig_managers():
 manager.window.show()
-------------------------------------
But I get an error that is very strange, as it references Tkinter even 
though I am using GTK:
-------------------------------------
Traceback (most recent call last):
 File 
"/home/kevin/workspace_seatree/SEATREE/py-drivers/py-hc/flowGUI.py", 
line 379, in editVisc
 manager.window.show()
 File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1724, in __getattr__
 return getattr(self.tk, attr)
AttributeError: show
-------------------------------------
Finally, I tried just not calling anything after p.frame() the second 
time through (besides doing the signal connecting again), and this time 
the plot window will show up, but signals will not be processed 
(including trying to close the plot with the 'x' on the window frame).
I also tried just embedding a FigureCanvasGTK object displaying the 
figure to my own gtk.Dialog object, which works for displaying the plot, 
but I couldn't figure out how to get the pylab events to be processed 
and connected (I need to modify the plot by clicking on parts of it). If 
I could figure out the even handling, this would actually be the 
preferred method of showing the plot. This is the code for this attempt:
-------------------------------------
self.dialog = gtk.Dialog(title=title, parent=parent, flags= 
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
self.canvas = FigureCanvasGTK(self.figure)
self.dialog.vbox.pack_start(self.canvas)
self.dialog.show_all()
self.dialog.show()
-------------------------------------
Does anyone have any suggestions? Thanks a ton for making it this far 
through my long message!
Kevin Milner
P.S. see full source here: (the pylab stuff is dirty cause it's in 
debugging stages)
See bottom for the p.show() call: 
http://geosys.usc.edu/projects/seatree/browser/py-drivers/py-hc/flowGUI.py
Event processing/plot creation and manipulation: 
http://geosys.usc.edu/projects/seatree/browser/py-drivers/py-hc/manipulate_hc.py
From: Wolfgang K. <wke...@go...> - 2008年02月21日 08:33:30
Dear all,
I use the scisoft package on leopard 10.5.2 (it is a package that 
creates its own python framework and delivers astronomical tools). I 
have recompiled tcl tkk 8.4 and 8.5 (which in hindsight was probably 
not a good idea). I also installed matplotlib 0.91.2. If i open 
ipython --pylab and do : plot([1,2,3]). I get the following output:
FigureCanvasAgg.draw
RendererAgg.__init__
RendererAgg.__init__ width=640.0, height=480.0
RendererAgg.__init__ _RendererAgg done
RendererAgg.__init__ done
Segmentation fault
thanks in advance
 Wolfgang
From: <kc1...@ya...> - 2008年02月20日 17:56:30
Ok, I know what the problem is. I was using a sample
setup.py posted by Stef and in his setup, he created a
"mpl-data" subdirectory under "dist" to store all of
the data files use by matplotlib. That's why
matplotlib couldn't find it without a set statement. 
After changing the name to "matplotlibdata",
everything works.
I also made changes to every one of the matplotlibrc
file I found in the installed copy of matplotlib to
invoke WXAgg - instead of TkAgg.
So for completeless, may be this will benefit other
matplotlib users, here's my py2exe script - tested
using python 2.3, latest wxpython and so forth.
Let say you wish to create an exe of the sample
multicolor.py program. Place multicolor.py in a
test\multicolor directory, and a copy of the following
script, have py2exe installed, and then just run it. 
You will end up with a dist subdirectory under
test\multicolor and that's where you'll find
multicolor.exe.
#====================
Kill_Distro = True
MatPlotLib_Wanted = True
def File_Exists( path ):
	res=os.path.isdir(path)
	if res==True:
		return res
	return os.path.isfile(path)
 
from distutils.core import setup
import py2exe
import sys
import os
import shutil
import glob
homedir= r"E:\test\Matplotlib\multicolor"
python = r"c:\Python25"	# Name of python directory
if File_Exists(python)==False:
	python = r"c:\Python23"	# Name of python directory
#
***********************************************************************
# Some suggests that old build/dist should be cleared
#
***********************************************************************
dist_paths = [ homedir+'\\build',
 homedir+'\\dist' ]
for path in dist_paths :
	if File_Exists ( path ) :
		shutil.rmtree ( path )
#
***********************************************************************
#
***********************************************************************
#
***********************************************************************
data_files = []
packages = []
includes = []
excludes = []
dll_excludes = []
data_files.append ( ( '', glob.glob ( 'templates_*.*'
) ) )
#
***********************************************************************
# For MatPlotLib
#
***********************************************************************
if MatPlotLib_Wanted :
	import matplotlib
	includes.append ( 'matplotlib.numerix.random_array' )
	packages.append ( 'matplotlib' )
	packages.append ( 'pytz' )
	def mpl_data_files(destpath, path):
		mpl_data=[]
		for x in glob.glob (path+'\\*.*' ):
			if os.path.isdir(x):
				mpl_data_files(destpath+'\\'+os.path.split(x)[1],
x)
			elif os.path.isfile(x):
				mpl_data.append(x)
		data_files.append ( ( destpath, mpl_data))
	mpl_data_files(r'matplotlibdata',
python+r'\Lib\site-packages\matplotlib\mpl-data')
	
	data_files.append ( ( r'matplotlibdata', glob.glob (
	
python+r'\Lib\site-packages\matplotlib\mpl-data\matplotlibrc'
)))
	data_files.append ( ( r'matplotlibdata\images',
glob.glob (
	
python+r'\Lib\site-packages\matplotlib\mpl-data\images\*.*'
)))
	data_files.append ( ( r'matplotlibdata\fonts\afm',
glob.glob (
	
python+r'\Lib\site-packages\matplotlib\mpl-data\fonts\afm\*.*'
)))
	data_files.append ( (
r'matplotlibdata\fonts\pdfcorefonts', glob.glob (
	
python+r'\Lib\site-packages\matplotlib\mpl-data\fonts\pdfcorefonts\*.*')))
	data_files.append ( ( r'matplotlibdata\fonts\ttf',
glob.glob (
	
python+r'\Lib\site-packages\matplotlib\mpl-data\fonts\ttf\*.*'
)))
	excludes.append ( '_gtkagg')
	excludes.append ( '_tkagg' )
	excludes.append ( '_agg2' )
	excludes.append ( '_cairo' )
	excludes.append ( '_cocoaagg' )
	excludes.append ( '_fltkagg' )
	excludes.append ( '_gtk' )
	excludes.append ( '_gtkcairo')
	excludes.append ( 'backend_qt' )
	excludes.append ( 'backend_qt4')
	excludes.append ( 'backend_qt4agg' )
	excludes.append ( 'backend_qtagg' )
	excludes.append ( 'backend_cairo' )
	excludes.append ( 'backend_cocoaagg' )
	excludes.append ( 'Tkconstants' )
	excludes.append ( 'Tkinter' )
	excludes.append ( 'tcl' )
	excludes.append ( "_imagingtk" )
	excludes.append ( "PIL._imagingtk" )
	excludes.append ( "ImageTk" )
	excludes.append ( "PIL.ImageTk" )
	excludes.append ( "FixTk" )
	dll_excludes.append ( 'libgdk-win32-2.0-0.dll' )
	dll_excludes.append ( 'libgdk_pixbuf-2.0-0.dll' )
	dll_excludes.append ( 'libgobject-2.0-0.dll')
	dll_excludes.append ( 'tcl84.dll' )
	dll_excludes.append ( 'tk84.dll' )
	dll_excludes.append ( 'tclpip84.dll' )
#
***********************************************************************
# seems not to be found (imported in brick.py)
#includes.append ( 'PyLab_Works_properties' )
#
***********************************************************************
#
***********************************************************************
# If run without args, build executables, in quiet
mode.
if len(sys.argv) == 1:
	sys.argv.append("py2exe")
setup (
		windows = ['multicolor.py'] ,
		options = {
			'py2exe' : {
			'includes' : includes,
			'excludes' : excludes,
			'dll_excludes' : dll_excludes,
			'packages' : packages,
			}
		},
		data_files = data_files
	)
result=0
#import subprocess
#result = subprocess.call (
# [ 'c:\Program Files\Inno Setup 4\ISCC.exe',
# homedir+'\\multicolor.iss'])
dist_paths = [ homeDir+'\\build',]
if (result==0) and Kill_Distro :
	for path in dist_paths :
		if File_Exists ( path ) :
			shutil.rmtree ( path )
> -----Original Message-----
> From: Werner F. Bruhin
[mailto:wer...@fr...] 
> Sent: Wednesday, February 20, 2008 5:24 AM
> To: kc1...@ya...
> Cc: mat...@li...
> Subject: Re: [Matplotlib-users] MatPlotLib + Py2exe,
backend problems ...
> 
> 
> Hi,
> 
> kc1...@ya... wrote:
> > I *finally* got this to work!!!
> >
> > Thanks to Werner's message, I found the culpit: 
the 
> matplotlibrc file 
> > copied to the dist directory contains the TkAgg
backend. 
> All I had to 
> > do is to change *that* file to say:
> >
> > backend : WXAgg
> >
> > Note that it's not the matplotlibrc in the
installed
> > copy - but the one in the resulting dist
directory.
> >
> > In addition, I have to do a:
> >
> > set MATPLOTLIBDATA=.\mpl-data
> > 
> You shouldn't need to do this. Note in 
> matplotlib.__init__.py, it looks 
> at a different folder if it is frozen by py2exe or
py2app or ...:
> # py2exe zips pure python, so still need special
check
> if getattr(sys,'frozen',None):
> path =
os.path.join(os.path.split(sys.path[0])[0], 
> 'matplotlibdata')
> 
> So, if you use the sample setup.py I posted a while
ago here 
> and on the 
> wxPython list it will create the matplotlibdata
folder in your 
> distribution (basically a copy of your mpl-data
folder) folder.
> > before I start the exe file. I don't know why
this is necessary 
> > because the code for _get_data_path appears to
look at that 
> directory 
> > by default but if I don't set this, it can't find
the data files.
> >
> > In any event, it works now - after bumping head
for 2
> > weeks!
> > 
> Hope the wall wasn't to hard, I always try this or
the wxPython list 
> after a day or two ;-) .
> 
> See you
> Werner
> 
--
John Henry
From: Nick Granger-B. <Nic...@xy...> - 2008年02月20日 13:24:33
Thanks Michael!
I'm new to this but I'm still kicking myself for not spotting it. Just
what I was looking for. 
Nick Granger-Brown
+44 (0)23 9249 6727 
-----Original Message-----
From: Michael Droettboom [mailto:md...@st...] 
Sent: 20 February 2008 13:21
To: Nick Granger-Brown
Cc: mat...@li...
Subject: Re: [Matplotlib-users] subplots with linked axes
It sounds like what you want is to use the "shared axis" functionality.
See the shared_axis_demo.py
http://matplotlib.sourceforge.net/examples/shared_axis_demo.py
Cheers,
Mike
Nick Granger-Brown wrote:
> I would like to plot two or three graphs as subplots in a figure and 
> control the axes such that when one graph is zoomed the others are 
> adjusted too. I was hoping there would be a notification mechanism 
> which would allow me to catch a rescaling of one subplot and redraw 
> the others in step. Can anyone suggest a method of doing this?
> 
> *Nick Granger-Brown*
> //
> 
> ______________________________________________________________________
> This email may contain privileged or confidential information, which 
> should only be used for the purpose for which it was sent by Xyratex. 
> No further rights or licenses are granted to use such information. If 
> you are not the intended recipient of this message, please notify the 
> sender by return and delete it. You may not use, copy, disclose or 
> rely on the information contained in it.
> 
> Internet email is susceptible to data corruption, interception and 
> unauthorised amendment for which Xyratex does not accept liability.
> While we have taken reasonable precautions to ensure that this email 
> is free of viruses, Xyratex does not accept liability for the presence
> of any computer viruses in this email, nor for any losses caused as a 
> result of viruses.
> 
> Xyratex Technology Limited (03134912), Registered in England & Wales, 
> Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA.
> 
> The Xyratex group of companies also includes, Xyratex Ltd, registered 
> in Bermuda, Xyratex International Inc, registered in California, 
> Xyratex
> (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) 
> Co Ltd registered in The People's Republic of China and Xyratex Japan 
> Limited registered in Japan.
> ______________________________________________________________________
> 
> 
> ----------------------------------------------------------------------
> --
> 
> ----------------------------------------------------------------------
> --- This SF.net email is sponsored by: Microsoft Defy all challenges. 
> Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> 
> 
> ----------------------------------------------------------------------
> --
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
______________________________________________________________________
This email may contain privileged or confidential information, which should only be used for the purpose for which it was sent by Xyratex. No further rights or licenses are granted to use such information. If you are not the intended recipient of this message, please notify the sender by return and delete it. You may not use, copy, disclose or rely on the information contained in it.
Internet email is susceptible to data corruption, interception and unauthorised amendment for which Xyratex does not accept liability. While we have taken reasonable precautions to ensure that this email is free of viruses, Xyratex does not accept liability for the presence of any computer viruses in this email, nor for any losses caused as a result of viruses.
Xyratex Technology Limited (03134912), Registered in England & Wales, Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA.
The Xyratex group of companies also includes, Xyratex Ltd, registered in Bermuda, Xyratex International Inc, registered in California, Xyratex (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) Co Ltd registered in The People's Republic of China and Xyratex Japan Limited registered in Japan.
______________________________________________________________________
From: Werner F. B. <wer...@fr...> - 2008年02月20日 13:23:58
Hi,
kc1...@ya... wrote:
> I *finally* got this to work!!! 
>
> Thanks to Werner's message, I found the culpit: the
> matplotlibrc file copied to the dist directory
> contains the TkAgg backend. All I had to do is to
> change *that* file to say:
>
> backend : WXAgg
>
> Note that it's not the matplotlibrc in the installed
> copy - but the one in the resulting dist directory.
>
> In addition, I have to do a:
>
> set MATPLOTLIBDATA=.\mpl-data
> 
You shouldn't need to do this. Note in matplotlib.__init__.py, it looks 
at a different folder if it is frozen by py2exe or py2app or ...:
 # py2exe zips pure python, so still need special check
 if getattr(sys,'frozen',None):
 path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
So, if you use the sample setup.py I posted a while ago here and on the 
wxPython list it will create the matplotlibdata folder in your 
distribution (basically a copy of your mpl-data folder) folder.
> before I start the exe file. I don't know why this is
> necessary because the code for _get_data_path appears
> to look at that directory by default but if I don't
> set this, it can't find the data files.
>
> In any event, it works now - after bumping head for 2
> weeks!
> 
Hope the wall wasn't to hard, I always try this or the wxPython list 
after a day or two ;-) .
See you
Werner
From: Michael D. <md...@st...> - 2008年02月20日 13:21:16
It sounds like what you want is to use the "shared axis" functionality.
See the shared_axis_demo.py
http://matplotlib.sourceforge.net/examples/shared_axis_demo.py
Cheers,
Mike
Nick Granger-Brown wrote:
> I would like to plot two or three graphs as subplots in a figure and 
> control the axes such that when one graph is zoomed the others are 
> adjusted too. I was hoping there would be a notification mechanism 
> which would allow me to catch a rescaling of one subplot and redraw the 
> others in step. Can anyone suggest a method of doing this?
> 
> *Nick Granger-Brown*
> // 
> 
> ______________________________________________________________________
> This email may contain privileged or confidential information, which 
> should only be used for the purpose for which it was sent by Xyratex. No 
> further rights or licenses are granted to use such information. If you 
> are not the intended recipient of this message, please notify the sender 
> by return and delete it. You may not use, copy, disclose or rely on the 
> information contained in it.
> 
> Internet email is susceptible to data corruption, interception and 
> unauthorised amendment for which Xyratex does not accept liability. 
> While we have taken reasonable precautions to ensure that this email is 
> free of viruses, Xyratex does not accept liability for the presence of 
> any computer viruses in this email, nor for any losses caused as a 
> result of viruses.
> 
> Xyratex Technology Limited (03134912), Registered in England & Wales, 
> Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA.
> 
> The Xyratex group of companies also includes, Xyratex Ltd, registered in 
> Bermuda, Xyratex International Inc, registered in California, Xyratex 
> (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) Co 
> Ltd registered in The People's Republic of China and Xyratex Japan 
> Limited registered in Japan.
> ______________________________________________________________________
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
3 messages has been excluded from this view by a project administrator.

Showing results of 356

<< < 1 .. 3 4 5 6 7 .. 15 > >> (Page 5 of 15)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /