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

Showing 11 results of 11

From: Ryan K. <rya...@gm...> - 2007年03月19日 23:04:37
Sorry, I just googled wxmpl and found your page and am now downloading
it. I may have a more intelligent question momentarily. You may
ignore that part of my response.
Ryan
On 3/19/07, Ryan Krauss <rya...@gm...> wrote:
> Thanks for your thoughts Ken. Sorry, I assumed a bit on the context
> of my comments. I have some data processing utility scripts and I
> want to now use with a WX application. The problem is that the
> utility modules were written without any thought of this future use in
> mind and in all of them I have something like
>
> from pylab import figure, cla, clf, plot, semiliogx, show, ...
>
> at the top. This makes them completely incompatible with embedding in
> a WX application. So, I need to re-write them and I want to know how
> to do that best. John had some suggestions and I had some new
> questions as I tried to act on his thoughts. So, the actual plotting
> functions don't have to be re-useable in both contexts, but it would
> be nice.
>
> I can't actually run your code because I don't have the wxmpl.py
> module. Looking at it, it looks like a really nice set of functions
> that work cleanly with embedding in a backend. How could I call one
> of the functions from the command line? Could I do something like:
> import plotting, pylab
> myfig = pylab.figure()
> plotting.plot_simple(myfig)
>
> and would I need any additional commands to actually show the figure?
>
> Let me know if that makes sense and please send me the wxmpl.py file
> or let me know where I can get it.
>
> Thanks again,
>
> Ryan
>
> On 3/19/07, Ken McIvor <mc...@ii...> wrote:
> > Ryan,
> >
> > In my (limited) experience, it's dicey to mix pylab's plotting
> > functionality and the OO API. I guess I'm a little unclear exactly
> > what your use case is for this. It sounds like you're goal is to
> > create a library of functions that operate on Figure instances,
> > perhaps so you can use them both interactively and as part of a
> > wxPython application.
> >
> > If that's the case, I'd recommend you try using pylab's gcf() and draw
> > () to acquire and redraw the current Figure instance from within
> > IPython. You can also save the return value of pylab's figure(),
> > which returns a Figure that's already been attached to the
> > appropriate renderer. This way you can use the OO API for plotting
> > without having to futz with the drawing machinery directly.
> >
> > This script might give you some ideas about how to structure your
> > code. It contains several of the MPL examples re-coded as functions
> > that accept a Figure instance and use the OO API for plotting.
> >
> > http://svn.csrri.iit.edu/mr-software/wxmpl/trunk/demos/plotting.py
> >
> > Ken
> >
>
From: Ken M. <mc...@ii...> - 2007年03月19日 20:57:55
Ryan,
In my (limited) experience, it's dicey to mix pylab's plotting 
functionality and the OO API. I guess I'm a little unclear exactly 
what your use case is for this. It sounds like you're goal is to 
create a library of functions that operate on Figure instances, 
perhaps so you can use them both interactively and as part of a 
wxPython application.
If that's the case, I'd recommend you try using pylab's gcf() and draw 
() to acquire and redraw the current Figure instance from within 
IPython. You can also save the return value of pylab's figure(), 
which returns a Figure that's already been attached to the 
appropriate renderer. This way you can use the OO API for plotting 
without having to futz with the drawing machinery directly.
This script might give you some ideas about how to structure your 
code. It contains several of the MPL examples re-coded as functions 
that accept a Figure instance and use the OO API for plotting.
	http://svn.csrri.iit.edu/mr-software/wxmpl/trunk/demos/plotting.py
Ken
From: Ryan K. <rya...@gm...> - 2007年03月19日 19:58:09
I am learning the hard way that I don't know as much about matplotlib
as I thought I did except for how to use pylab.
I think I have managed to create a figure, add an axis, and plot
something on it without pylab, but I don't know how to do the
equivalent of show(). draw() needs a renderder and I can't seem to
figure out how to create one. Here is what I have done so far:
myfig = pylab.Figure()
myaxes=myfig.add_axes((0,1,0,1))
t=arange(0,1,0.01)
y=sin(2*pi*t)
myaxes.plot(t,y)
What do I need to do to show the plot from the command line in IPython
(i.e. if I actually want to use pylab instead of OO)?
I may be going about this the wrong way and it may be easier just to
set up some imports of pylab that only trigger inside of functions,
but I would like to have functions that are useful either from the
IPython command line or in OOP situations. Following the examples
for WX, I am doing this at the top of my OOP modules:
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.figure import Figure
.
.
.
	
class mplpanel(wx.Panel):
 def __init__(self, parent):
 wx.Panel.__init__(self, parent, -1)
 self.fig = Figure((5,5), 75)
 self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
And the my drawing commands operate on self.fig and then the last line
of all plotting functions is self.canvas.draw().
So, it would be nice if my utility functions took a figure instance as
an input and operated on it.
Am I making any sense? Am I going about this revision in a good way?
Thanks,
Ryan
On 3/15/07, Ryan Krauss <rya...@gm...> wrote:
> Thanks John. I know I have some clean up to do, I just want to do it
> right so it isn't an annual (or more often) thing....
>
> On 3/15/07, John Hunter <jd...@gm...> wrote:
> > On 3/15/07, Ryan Krauss <rya...@gm...> wrote:
> >
> > > How should I be using matplotlib/pylab in my utility scripts so that
> > > they are compatible with embedding in wx?
> >
> > A good rule of thumb is to never import pylab at the top level for
> > modules that need to be imported. In my own code, I often do
> > something like
> >
> > def somefunc(figfunc):
> > fig = figfunc()
> > ax = fig.add_subplot(111)
> > ax.plot([1,2,3])
> >
> > and then I can call it with
> >
> > somefunc(pylab.figure)
> >
> > or a custom func that generates a GUI embedded figure instance. Eg,
> > in my GTKApps, I have a functor like gtk_figure that returns a
> > function that creates a figure embedded in a GTK window.
> >
> > In basemap, Jeffrey Whitaker does something like the following
> >
> > def somefunc(ax=None):
> > if ax is None:
> > import pylab
> > ax = pylab.gca()
> >
> > Here the pylab import is triggered only when the function is called
> > with default arguments. That way you can use it from GUI code without
> > triggering a pylab import like
> >
> > somefunc(ax)
> >
> > and from other code where you want pylab do do everything with
> >
> > somefunc()
> >
> > I'm afraid you have some cleanup to do..... Mixing pylab with
> > embedded GUI code is a recipe for pain and misery.
> >
> > JDH
> >
>
From: Eric F. <ef...@ha...> - 2007年03月19日 17:59:20
Pellegrini Eric wrote:
> Hi,
> 
> I have some problems to combine a matshow object with a canvas. Here is 
> a little piece of code that illustrates my problem. It displays a 
> matshow object when pressing a button.
> I would like to embed the matshow object into a canvas of a fixed 
> dimension. The code I wrote does the opposite i.e. it is the canvas that 
> adapts its size and not the matshow object. Would you have any hints ?
> 
I suspect this problem will be solved by a change I made to svn last 
night, providing a matshow Axes method that you would use in place of 
pylab.matshow. Axes.matshow() simply makes and returns the image; it 
does not make a figure or set its dimensions, so you have full control 
over that.
Eric
> 
> ******************************************************************************
> from Tkinter import *
> from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
> import pylab
> 
> def display():
> mat = pylab.zeros((100,100))
> pylab.ioff()
> image = pylab.matshow(mat)
> pylab.ion()
> can = FigureCanvasTkAgg(image, master=frame)
> can.show()
> can.get_tk_widget().grid(row = 0,column = 0)
> 
> root = Tk()
> frame = Frame(root)
> frame.grid(row = 0,column = 0)
> canvas = Canvas(frame, width = 240, height = 240, relief = "sunken", bg 
> = "white") 
> canvas.grid()
> 
> button = Button(root,text="DisplayMatrix",command = display)
> button.grid(row = 1,column = 0)
> ****************************************************************************
> 
> Thank you very much
> 
> Eric
> 
> ------------------------------------------------------------------------
> Découvrez une nouvelle façon d'obtenir des réponses à toutes vos 
> questions ! Profitez des connaissances, des opinions et des expériences 
> des internautes sur Yahoo! Questions/Réponses 
> <http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>.
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Victoria G. L. <la...@st...> - 2007年03月19日 17:33:36
Thanks!! I really appreciate the fast action!
Vicki
Eric Firing wrote:
> Victoria G. Laidler wrote:
> [...]
>> It would be extremely useful if xlabel, ylabel, title, and possibly 
>> legend could be made smart enough to attempt to call a __str__ method 
>> on the objects they are passed, so that xlabel(MyObject) behaves as 
>> intelligently as "print MyObject" does.
> [...]
>> Any chance of getting this implemented?
>
> Vicki,
>
> Done in svn.
>
> Eric
>>
>> Hopefully,
>> Vicki Laidler, STScI
From: Matthieu B. <mat...@gm...> - 2007年03月19日 09:53:41
Hi,
I tried it again, and now it works like charm with numpy arrays. I do not
understand why it did not work before, but it works now, it's all that
matters :)
But 3D is another problem...
Matthieu
2007年3月14日, Eric Firing <ef...@ha...>:
>
> Matthieu Brucher wrote:
> > What version of mpl are you using?
> >
> >
> >
> > The latest, I compiled it from the source as FC5 has a very old version
> > - can't update myself the distribution -
> >
> >
> > In recent versions, the collections should accept 2D numpy arrays as
> > well as any sequence of tuples (and several other possibilities).
> >
> >
> >
> > For 2D plots, numpy arrays is accepted - but not for colors, it tells me
> > there is a problem with tuples, I do not remember exactly, but I can
> > check the error tomorrow -.
>
> Mathieu,
>
> Did you come up with a minimal example of this? If so, please send it
> to me directly. I would like to follow up on it.
>
> Thanks.
>
> Eric
>
From: Pellegrini E. <eri...@ya...> - 2007年03月19日 09:20:36
Hi,
I have some problems to combine a matshow object with a canvas. Here is a little piece of code that illustrates my problem. It displays a matshow object when pressing a button. 
I would like to embed the matshow object into a canvas of a fixed dimension. The code I wrote does the opposite i.e. it is the canvas that adapts its size and not the matshow object. Would you have any hints ?
******************************************************************************
from Tkinter import *
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import pylab
def display():
 mat = pylab.zeros((100,100))
 pylab.ioff()
 image = pylab.matshow(mat)
 pylab.ion()
 can = FigureCanvasTkAgg(image, master=frame)
 can.show()
 can.get_tk_widget().grid(row = 0,column = 0)
root = Tk()
frame = Frame(root)
frame.grid(row = 0,column = 0)
canvas = Canvas(frame, width = 240, height = 240, relief = "sunken", bg = "white") 
canvas.grid()
button = Button(root,text="DisplayMatrix",command = display)
button.grid(row = 1,column = 0)
****************************************************************************
Thank you very much
Eric
 		
---------------------------------
 Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
From: Suresh P. <sto...@ya...> - 2007年03月19日 07:39:13
On 2007年3月18日, Eric Firing wrote:
> One of the matshow anomalies is that it is a pylab function only instead
> of a wrapper for an Axes method, so I made a new Axes.matshow(), and a
> temporary matshow1() pylab function that calls it. Differences between
> matshow() and matshow1():
>
> 1) The latter labels the *centers* of the squares representing the
> matrix elements, starting from zero. Tick values are consequently integers.
>
> 2) matshow1 uses the same function as matshow (figaspect()) to determine
> the window dimensions, but keeps the matrix elements square when they
> would be stretched in matshow. I can change this back to the matshow
> behavior if desired.
You may recall from our previous discussions that I would rather you not 
change (2) back to matshow behaviour. Although I am not sure if you say 
you will force the aspect ratio to be equal, or that you will preserve the 
aspect ratio of the matrix as specified? (As you may recall, I was 
unhappy with the matrix being stretched when other elements were added to 
the figure.)
And thanks for #1.
From: Eric F. <ef...@ha...> - 2007年03月19日 07:27:11
Fernando Perez wrote:
[...]
> Frankly, I don't care how it's done: I wrote matshow long ago, back
> when axis('scaled') didn't exist in the first place. If the same
> result can be achieved by other means that are cleaner, I'm sure John
> will accept a patch.
One of the matshow anomalies is that it is a pylab function only instead 
of a wrapper for an Axes method, so I made a new Axes.matshow(), and a 
temporary matshow1() pylab function that calls it. Differences between 
matshow() and matshow1():
1) The latter labels the *centers* of the squares representing the 
matrix elements, starting from zero. Tick values are consequently integers.
2) matshow1 uses the same function as matshow (figaspect()) to determine 
the window dimensions, but keeps the matrix elements square when they 
would be stretched in matshow. I can change this back to the matshow 
behavior if desired.
> 
> All I need regularly in my work is the ability to plot a matrix such
> that both the axis AND the enclosing figure (which determines the size
> of the resulting EPS files for publications or talks) have the aspect
> ratio of the actual matrix. How that result is achieved is really
> immaterial to me.
I suspect that what you would actually prefer is better automated figure 
sizing so that it would always nicely enclose the axes with their 
labels, titles, etc., correct? There is nothing magic about having the 
actual aspect ratio of the figure exactly match that of the axes box?
(Not that I can easily achieve the nice wrapping result--this is just to 
clarify the ideal.)
> 
> matshow does what I need so I use it, but I have no particular
> attachment to the code other than the fact that it happens to work
> correctly. That's a bonus in my book.
Absolutely!
Another anomaly of matshow (presently preserved in matshow1) is the 
returnall kwarg; this seems like the sort of thing that should either be 
supported by all pylab functions, or by none. The argument for none is 
that one can easily use gcf() and gca() to get the other two arguments. 
 Do you want to keep the returnall kwarg?
Eric
From: <kc1...@ya...> - 2007年03月19日 05:49:18
Thanks for the reply, Jouni.=0A=0AI am running Python 2.3 on Windows XP, la=
test version of MPL.=0A=0AI'll see if I can reproduce the problem using sta=
ndard examples.=0A=0A=0A=0ARegards,=0A=0A> -----Original Message-----=0A> F=
rom: mat...@li... =0A> [mailto:matplotlib=
-us...@li...] On =0A> Behalf Of Jouni K Sepp=E4nen=
=0A> Sent: Saturday, March 17, 2007 1:06 PM=0A> To: matplotlib-users@lists.=
sourceforge.net=0A> Subject: Re: [Matplotlib-users] PDF Backend problem sti=
ll unresolved=0A> =0A> =0A> <kc106_2005-matplotlib@...> writes:=0A> =0A> >=
 > Starting with the 9th page, MPL chokes at line 1084 in =0A> > > backend_=
pdf.py=0A> > Jouni posted a couple of responses witih suggestions in CVS =
=0A> syntax but =0A> > I was unable to use that information.=0A> =0A> I had=
 to take my laptop to be to be repaired, so I can't do =0A> much work on Ma=
tplotlib right now. In the meantime, please =0A> post some more information=
: what version of Python and =0A> Matplotlib is this, on which platform, ca=
n you reduce your =0A> code to a small example that exhibits the bug, what =
output do =0A> you get with "verbose.level: debug"?=0A> =0A> --=0A> Jouni=
=0A> =0A> =0A> =0A> -------------------------------------------------------=
-------=0A> -----------=0A> Take Surveys. Earn Cash. Influence the Future o=
f IT=0A> Join SourceForge.net's Techsay panel and you'll get the =0A> chanc=
e to share your opinions on IT & business topics through =0A> brief surveys=
-and earn cash =0A> http://www.techsay.com/default.php?page=3Djoin.php&p=3D=
sourceforge=0A&CID=3DDEVDEV=0A_____________________________________________=
__=0AMatplotlib-users mailing list Mat...@li...=
=0Ahttps://lists.sourceforge.net/lists/listinfo/matplotlib-users=0A=0A =0A-=
-=0AJohn Henry=0A=0A
From: Fernando P. <fpe...@gm...> - 2007年03月19日 04:00:28
On 1/11/07, belinda thom <bt...@cs...> wrote:
> Hi,
>
> > With the exception of ipython -pylab, noone is forcing you to import
> > *. And on the subject, Fernando, perhaps we should support a pylab
> > mode in ipython which doesn't dump the pylab namespace (or maybe just
> > dumps the required figure, show, close, nx), but does the interactive
> > backend stuff.
>
> In the meantime, I did the following to my local dev copy of IPython:
> Instead of the existing "import..." viq exec into user namespace, I do:
> import pylab as P
> import numpy as N
> import matplotlib as M
>
> It would be nice if controlling this type of thing was configurable.
It now is: set
pylab_import_all 0
in your ~/.ipython/ipythonrc file, and when using -pylab, ipython will
only import the names 'matplotlib' and 'pylab', but it will NOT do
from pylab import *
anymore.
Cheers,
f

Showing 11 results of 11

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