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





Showing 4 results of 4

From: David A. <irb...@gm...> - 2011年02月27日 22:49:45
Attachments: Figure.png
Hi All,
I'm looking for some suggestions about two problems:
1) I'm converting some figure generating code from IDL into
Python/matplotlib. Image attached showing this figure.
IDL being a functional programming language for the most part,
creating wrappers around various subroutines is trivial and generally
the simplest way to modify their behavior.
For example, in dealing with phase data (which can take values between
0o and 360o, and are 'wrapped' around this interval, such that 270o +
180o = 90o and so on), I have some stuff in IDL that instead over
simply 'overplotting' some (x,y) data, it will do a quick loop and
instead overplot (x, y + n * 360o) for n = -1, ..., 1 (or some other
number of repetitions, you get the idea).
Now, in matplotlib, while I can do this pretty easily, I suspect there
are better ways? I suppose I could write a subclass of
matplotlib.axes.Axes for example, that does the 360o repetition itself
across not just the plot() method but for others also? But
implementing a whole new class for this may be complicated, and I am
sort of lost as to how I would then get that working with the pylab
stateful interface?
I'm reasonably new to OO programming, and I'm still getting my head
round the 'best' way to do things like this.
Alternatively, having a class that describes individual data points, I
could define a plot() method for them?
class MyData():
 ...
 plot(self, axes):
 ...
 axes.plot(self.x, self.y + n * 360)
But then, that seems to 'break' some rules, as I don't see much
matplotlib code in which you do 'data.plot()' as opposed to
'axes.plot()' - the order seems wrong?
2) Somewhat similar to the first question. The figure includes (at
the top) some ancillary data (showing lengths of orbit and year
numbers). In IDL its done simply by filling polygons in normal / page
coordinates - but again, I think it could be better done using OO
somehow? Effectively, that top row could be thought of as a separate
subplot. What would be the efficient / sensible / pythonic way to go
about reproducing this. Another subclass of Axes?
Many thanks,
Dave
From: Benjamin R. <ben...@ou...> - 2011年02月27日 17:39:27
On Sun, Feb 27, 2011 at 6:48 AM, andrea crotti <and...@gm...>wrote:
> 2011年2月18日 Benjamin Root <ben...@ou...>:
> >
> >
> > Automatic layouts are difficult to do in matplotlib. This was a design
> > decision trade-off made early in its development. Instead of having
> > matplotlib determining optimal layouts and such, the developers decided
> that
> > it would be better to give the programmers full control over all
> placement,
> > and merely establish good defaults.
> >
> > Just for completeness, I like this page because it talks about the
> multiple
> > different ways you can specify coordinates for a text object (and
> > corresponding arrow) for placement:
> >
> > http://matplotlib.sourceforge.net/users/annotations.html
> >
> > Knowing ahead of time how much space an annotation will take is very
> > difficult, especially if your text involves any LaTeX symbols. However,
> it
> > is possible. The Text object has some method calls that can return
> bounding
> > boxes for the text object after it is made:
> >
> >
> http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.text.Text.get_bbox_patch
> >
> http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.text.Text.get_window_extent
> >
> > I haven't used these myself, so I don't know exactly what is the
> difference
> > between them (I think they are different coordinate systems). Once
> knowing
> > the size of your text object, you can change the position of the object
> > using its set_position() method. It is tricky, but if positioning and
> > layout is very important to you, it is possible to do.
> >
> > I hope this helps!
> >
> > Ben Root
> >
>
> Thanks for the answer, I tried something out but well it's not so trivial.
> And I think it doesn't make much sense to add the text inside the same
> plot, so I thought about subplot.
>
> I want a bigger subplot on top and one are splitted in two parts below it.
>
> But if I do
> subplot(221)
> ...
> subplot(222)
> ...
> subplot(223)
> ...
> it doesn't like it, and I didn't find any example which has this "more
> advanced" subplotting.
>
> Once that works it might be easier to compute the size that I need
> since the coordinate for the subplot are always from 0 to 1...
>
Andrea,
If you would like more advanced control over your subplots, matplotlib
v1.0.x has the new gridspec feature:
http://matplotlib.sourceforge.net/users/whats_new.html#sophisticated-subplot-grid-layout
Maybe this can help you?
Ben Root
From: andrea c. <and...@gm...> - 2011年02月27日 12:48:30
2011年2月18日 Benjamin Root <ben...@ou...>:
>
>
> Automatic layouts are difficult to do in matplotlib. This was a design
> decision trade-off made early in its development. Instead of having
> matplotlib determining optimal layouts and such, the developers decided that
> it would be better to give the programmers full control over all placement,
> and merely establish good defaults.
>
> Just for completeness, I like this page because it talks about the multiple
> different ways you can specify coordinates for a text object (and
> corresponding arrow) for placement:
>
> http://matplotlib.sourceforge.net/users/annotations.html
>
> Knowing ahead of time how much space an annotation will take is very
> difficult, especially if your text involves any LaTeX symbols. However, it
> is possible. The Text object has some method calls that can return bounding
> boxes for the text object after it is made:
>
> http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.text.Text.get_bbox_patch
> http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.text.Text.get_window_extent
>
> I haven't used these myself, so I don't know exactly what is the difference
> between them (I think they are different coordinate systems). Once knowing
> the size of your text object, you can change the position of the object
> using its set_position() method. It is tricky, but if positioning and
> layout is very important to you, it is possible to do.
>
> I hope this helps!
>
> Ben Root
>
Thanks for the answer, I tried something out but well it's not so trivial.
And I think it doesn't make much sense to add the text inside the same
plot, so I thought about subplot.
I want a bigger subplot on top and one are splitted in two parts below it.
But if I do
subplot(221)
...
subplot(222)
...
subplot(223)
...
it doesn't like it, and I didn't find any example which has this "more
advanced" subplotting.
Once that works it might be easier to compute the size that I need
since the coordinate for the subplot are always from 0 to 1...
From: Sandy Oz <ale...@co...> - 2011年02月27日 08:30:58
Hello everyone,
I'm building and application which will display a collection 
of several wxpanels each of which displays a 
FigureCanvasWxAgg with a particular subplot.
The user is allowed to remove these panels.
However, after a panel is deleted (call wxPanel.Destroy()), 
and the mouse moves over the now empty space, I get the 
following exception:
 File 
"/usr/lib/pymodules/python2.6/matplotlib/backends/backend_wx.py", 
line 1316, in _onMotion
 FigureCanvasBase.motion_notify_event(self, x, y, 
guiEvent=evt)
 File 
"/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", 
line 1244, in motion_notify_event
 guiEvent=guiEvent)
 File 
"/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", 
line 899, in __init__
 LocationEvent.__init__(self, name, canvas, x, y, 
guiEvent=guiEvent)
 File 
"/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", 
line 817, in __init__
 self._update_enter_leave()
 File 
"/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", 
line 844, in _update_enter_leave
 last.canvas.callbacks.process('axes_leave_event', last)
 File 
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", 
line 14586, in __getattr__
 raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the 
FigureCanvasWxAgg object has been deleted, attribute access 
no longer allowed.
Looks like the deleted canvas is still listening for mouse 
move events.
How can I prevent this?
Thank you,
Sandy

Showing 4 results of 4

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