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

Showing 9 results of 9

From: PGM <pgm...@gm...> - 2006年06月21日 20:09:11
John
> Well, we could keep it simple and just give a hook to custom figures.
> If a user wants a custom subplot
>
> class MyFigure(Figure):
> def add_my_subplot(self, *args, **kwargs):
> self.axes.append(MySubplot(*args, **kwargs))
>
> Is there any downside to this approach? It seems like if you are
> going to the trouble to create a custom figure, you might was well
> handle your own custom subplots there rather than in the Figure class
> proper.
Try that:
fig = figure(FigureClass=MyFigure)
fsplist = [Subplot(fig,211), Subplot(fig,212), Subplot(fig,211)]
for fsp in fsplist: 
	fig.add_my_subplot(fsp)
You should end up with three subplots, with fsp[-1] and fsp[0] at the same 
location 211, when in fact you really need only two subplots (assume that the 
last one is an updated version of the first one, which is not obvious in this 
example....). In short, the `add_my_subplot` does not reproduce the behaviour 
of `add_subplot`.
FYI, when I started working on that yesterday evening, I wrote something quite 
similar to what you're suggesting. Then, I needed to go through all my 
subplots, and instead of checking the `figure.axes` list, I checked 
`fig._axstack_elements`. Which was empty, of course. So I added a 
`self._axstack.push(MySubplot`) to `add_my_subplot`, then noted that I had to 
put back the tests on whether the dubplot was already present or not 
(figure._seen), and before soon, I was just copying the basic 'add_subplot()' 
around that `self.axes.append(MySubplot)`. As I have several custom figures 
with custom subplots, I realized it'd be cleaner to just make a 
`add_generic_subplot` instead of copying/pasting most of the code.
I'm realizing now that had I worked on `figure.axes` straight away, I would 
never have had the proper behaviour, so I've been lucky.
From: James C. <mr...@gm...> - 2006年06月21日 20:08:57
Hi,
What's a good way to create a 2d gaussian kernel with pylab?
I want a 9x9 matrix with 1.0 in the center, and 0.0 in the corners,
and a gaussian distribution from the center out.
Thanks,
-Jim
From: James C. <mr...@gm...> - 2006年06月21日 19:36:56
Hi,
What's a good way to create a 2d gaussian kernel with pylab?
I want a 9x9 matrix with 1.0 in the center, and 0.0 in the corners,
and a nice gaussian distribution from the center out.
Thanks!
-Jim
From: John H. <jdh...@ac...> - 2006年06月21日 19:14:15
>>>>> "PGM" == PGM <pgm...@gm...> writes:
 PGM> Now, till we (you ;)) are it, what about updating
 PGM> Figure.add_subplot() to call user-defined subplots ? I wrote
 PGM> something along the lines below for my own needs, but that
 PGM> might be a useful addition...
Well, we could keep it simple and just give a hook to custom figures.
If a user wants a custom subplot
class MyFigure(Figure):
 def add_my_subplot(self, *args, **kwargs): 
 self.axes.append(MySubplot(*args, **kwargs))
fig = figure(FigureClass=MyFigure)
fig.add_my_subplot(111)
Is there any downside to this approach? It seems like if you are
going to the trouble to create a custom figure, you might was well
handle your own custom subplots there rather than in the Figure class
proper.
JDH
From: PGM <pgm...@gm...> - 2006年06月21日 18:51:47
John
> I modified pylab (and every backend, damn there are a lot) to support
> this feature. 
Wow, impressive ! Thx a lot
> Now you can pass a FigureClass kwarg to the pylab 
> figure function. With minimal extra work, we could support defaults
> so you don't have to explicitly pass it. But before I go ahead with
> this, take a look and see if this is more like what you had in mind.
Yep indeed, that's pretty much what I was considering. And parsing the 
MyFigure arguments through keywords seems the easiest, I'll keep that in mind 
(I used optional arguments *args, as they're not used in Figure, but that's 
trickier to keep track of).
Now, till we (you ;)) are it, what about updating Figure.add_subplot() to call 
user-defined subplots ? I wrote something along the lines below for my own 
needs, but that might be a useful addition...
Initial add_subplot
add_subplot(self, *args, **kwargs):
	...
 if isinstance(args[0], Subplot) or isinstance(args, PolarSubplot):
 a = args[0]
 a.set_figure(self)
 else:
 ispolar = popd(kwargs, 'polar', False)
 if ispolar:
 a = PolarSubplot(self, *args, **kwargs)
 else:
 a = Subplot(self, *args, **kwargs)
	...
Modified add_subplot
add_generic_subplot(figure, subplotclass, *args, **kwargs):
	...
 if isinstance(args[0], Subplot):
 a = args[0]
 a.set_figure(self)
 else:
 a = subplotclass(self, *args, **kwargs)
	...
That way, if you need a PolarSubplot, you can still get it. Well, we'd have to 
make PolarSubplot a subclass of Subplot instead of Subplotbase, but that 
should be easy to implmnt.
> from pylab import figure, show, nx
> from matplotlib.figure import Figure
>
> class MyFigure(Figure):
> def __init__(self, *args, **kwargs):
> """
> custom kwarg figtitle is a figure title
> """
> figtitle = kwargs.pop('figtitle', 'hi mom')
> Figure.__init__(self, *args, **kwargs)
> self.text(0.5, 0.95, figtitle, ha='center')
>
> fig = figure(FigureClass=MyFigure, figtitle='my title')
> ax = fig.add_subplot(111)
> ax.plot([1,2,3])
> fig.savefig('test.png')
> fig.savefig('test.ps')
> show()
>
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: John P. <joh...@st...> - 2006年06月21日 15:11:14
Hi John
Thanks for that. I thought I recalled seeing the example you mentioned, 
but obviously it was a different one.
I tried the code you gave me and it worked perfectly. Thanks very much!
Cheers
JP
John Hunter wrote:
> The approach I suggested doesn't affect the x and y axes, only the
> coord in the toolbar.
> 
...
> Try
>
> def myfmt(x,y): return 'myfmt (%1.2f, %1.2f)'%(x,y) 
> ax = subplot(111)
> ax.format_coord = myfmt
> ax.plot([1,2,3])
>
> JDH
>
> 
>
-- 
John Pye
Department of Mechanical and Manufacturing Engineering
University of New South Wales, Sydney, Australia
http://pye.dyndns.org/
From: John H. <jdh...@ac...> - 2006年06月21日 13:35:36
>>>>> "John" == John Pye <joh...@st...> writes:
 John> Hi all I have an application that uses Matplotlib to display
 John> incidence matrices for systems of equations. I have linked
 John> up the figure window with 'event handling' so that mouseover
 John> on the plot shows the variables/relations corresponding to
 John> the pointed-to coordinates, but at present this is only
 John> output to the console, as per the example in the User's
 John> Guide.
 John> I'd like to switch it over so that the variable and relation
 John> name replaces the 'x=' and 'y=' text in the bottom-left of
 John> the Figure window.
 John> Is there anything in the event handling mechanism that would
 John> facilitate me doing this? Is there a way I can do this
 John> without having to patch matplotlib? It seems like this would
 John> be a generally useful addition to the event handling stuff
 John> for figure windows.
The Axes class has two attributes, fmt_xdata and fmt_ydata, which if
defined are callables that take the x and y coords as floats and
return the format string used to format that bit of text that goes
into the toolbar. The default is to use the xaxis and yaxis
Formatters. See examples/date_demo1.py for some example code.
JDH
From: John H. <jdh...@ac...> - 2006年06月21日 13:28:48
>>>>> "Pierre" == Pierre GM <pgm...@ma...> writes:
 Pierre> John, Thx for your answer. IMHO, the problem lies really
 Pierre> with Figure, not Canvas. I'd need the Canvas, whatever
 Pierre> backend defines it, recognizes that the figure is not a
 Pierre> classical 'Figure' , but a subclass of it, with its own
 Pierre> special properties/methods. I gonna think aloud for a
 Pierre> minute
I modified pylab (and every backend, damn there are a lot) to support
this feature. Now you can pass a FigureClass kwarg to the pylab
figure function. With minimal extra work, we could support defaults
so you don't have to explicitly pass it. But before I go ahead with
this, take a look and see if this is more like what you had in mind. 
from pylab import figure, show, nx
from matplotlib.figure import Figure
class MyFigure(Figure):
 def __init__(self, *args, **kwargs):
 """
 custom kwarg figtitle is a figure title
 """
 figtitle = kwargs.pop('figtitle', 'hi mom')
 Figure.__init__(self, *args, **kwargs)
 self.text(0.5, 0.95, figtitle, ha='center')
fig = figure(FigureClass=MyFigure, figtitle='my title')
ax = fig.add_subplot(111)
ax.plot([1,2,3])
fig.savefig('test.png')
fig.savefig('test.ps')
show()
 
From: John P. <joh...@st...> - 2006年06月21日 01:48:42
Hi all
I have an application that uses Matplotlib to display incidence matrices 
for systems of equations. I have linked up the figure window with 'event 
handling' so that mouseover on the plot shows the variables/relations 
corresponding to the pointed-to coordinates, but at present this is only 
output to the console, as per the example in the User's Guide.
I'd like to switch it over so that the variable and relation name 
replaces the 'x=' and 'y=' text in the bottom-left of the Figure window.
Is there anything in the event handling mechanism that would facilitate 
me doing this? Is there a way I can do this without having to patch 
matplotlib? It seems like this would be a generally useful addition to 
the event handling stuff for figure windows.
Cheers
JP
-- 
John Pye
Department of Mechanical and Manufacturing Engineering
University of New South Wales, Sydney, Australia
http://pye.dyndns.org/

Showing 9 results of 9

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





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

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

More information about our ad policies

Ad destination/click URL:

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