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


Showing 2 results of 2

From: Leighton P. <lp...@sc...> - 2005年03月25日 14:24:20
Hi Matt,=0D=0A=0D=0AOn Thu, 2005年03月24日 at 22:48 -0600, Matt Newville wrote:=0D=
=0A> I'm no expert in wxPython or matplotlib, but there are a few=0D=0A> po=
ssible problems with your script:=0D=0A> - For the timing method, I think =
the issue is simply how fast=20=0D=0A> you can send Timer events. You'r=
e doing them every 20ms,=20=0D=0A> which is pretty fast (I'm willing to =
take the blame for=20=0D=0A> sending you an example that goes that fast!=
). If you change =20=0D=0A> that to 200ms, I'll bet you will see more u=
pdates.=20=0D=0A=0D=0AThe timer was working pretty well on all three system=
s at 20ms intervals=0D=0A- no blame to apportion there! ;)=0D=0A=0D=0A> - =
The Loop method [...]=0D=0A> - The Custom Event [...]=0D=0A> For all these=
, I would think that adding=0D=0A> self.Update()=0D=0A> should help. =0D=
=0A=0D=0AI added self.Update() to each frame on the update event, and that =
fixed=0D=0Amy problem on OS X. I'm guessing that the wx.Timer events force =
an=0D=0Aupdate=3F=0D=0A=0D=0A> I think you want to avoid the Loop method, a=
s it can block other=0D=0A> widget events. I believe that what you want is =
to replot the=0D=0A> figure when (a) the data has changed and (b) some mini=
mum time=0D=0A> has elapsed since the last drawing. One approach is to use=
 a=0D=0A> timer to periodically check (this sets the minimun time) for new=0D=
=0A> data, and redraw the plot when there's new data.=0D=0A=0D=0AI'm less b=
othered about the minimum time, though I do like the idea of=0D=0Asetting u=
p a timer in the monitor frame, and polling for a changed state=0D=0Ain the=
 object it's monitoring, and might change part of my design to=0D=0Aimpleme=
nt that in the 'real' code.=0D=0A=0D=0A> Another approach is to trigger on =
changes in the data, possibly=0D=0A> saving the timestamp when a redraw is =
done so as to not draw too=0D=0A> often. Which method to use probably depe=
nds on how easily it is=0D=0A> to detect and act upon changes to the data. =
=20=0D=0A=0D=0AThis is what I'm doing in the full application (bar the time=
stamp) at=0D=0Athe moment - it's under a 'data-push' model at the moment.=0D=
=0A=0D=0A> Finally, you may also consider putting the data-intensive code i=
n a separate=0D=0A> thread from the GUI.=0D=0A=0D=0AAh, threads... I'll st=
ick to the self.Update() for now ;)=0D=0A=0D=0A> But I think the main issue=
 is to not try to redraw the plot 50=0D=0A> times per second. ;).=0D=0A=0D=0A=
<grin> My algorithm coding isn't good enough for that to be an issue,=0D=0A=
anyway. But I think the root of the cross-platform problem might lie=0D=0A=
elsewhere, and the different steps I had to take on each OSs are=0D=0Apuzzl=
ing me. On Windows I didn't need to add self.Update() calls, as=0D=0Aevery=
thing worked first time. On Linux, the plot updated without resort=0D=0Ato=
 self.Update(), but the buttons didn't - and adding the self.Update()=0D=0A=
calls only caused the buttons to appear blank, rather than not=0D=0Achange.=
=2E.=20=0D=0A=0D=0AOn OS X, however, adding the self.Update() calls made it=
 run exactly how=0D=0AI wanted (and expected). I'm guessing that the wx.Ti=
mer events are=0D=0Apropagating Update() calls to both frames within wx, wh=
ile the other two=0D=0Amethods aren't. Except in Windows. Hmm... more re=
ading ahead for me.=0D=0A=0D=0AStill, most importantly (for me) my problem =
is solved, and I've learnt=0D=0Athings about wx events, and cross-platform =
issues. Many thanks again=0D=0Afor your help, Matt - I'd have been flounde=
ring much longer without it.=0D=0ANow I'll try to solve some of the non-mat=
plotlib-related issues ;)=0D=0A=0D=0ACheers,=0D=0A=0D=0A--=20=0D=0ADr Leigh=
ton Pritchard AMRSC=0D=0AD131, Plant-Pathogen Interactions, Scottish Crop R=
esearch Institute=0D=0AInvergowrie, Dundee, Scotland, DD2 5DA, UK=0D=0AT: +=
44 (0)1382 562731 x2405 F: +44 (0)1382 568578=0D=0AE: lp...@sc....u=
k W: http://bioinf.scri.sari.ac.uk/lp=0D=0AGPG/PGP: FEFC205C E58BA41B ht=
tp://www.keyserver.net =20=0D=0A(If the signature does not verif=
y, please remove the SCRI disclaimer)=0D=0A_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ =
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _=0D=0A=0D=0ADISCLAIMER:=0D=0A=0D=
=0AThis email is from the Scottish Crop Research Institute, but the views =0D=
=0Aexpressed by the sender are not necessarily the views of SCRI and its =0D=
=0Asubsidiaries. This email and any files transmitted with it are confiden=
tial=20=0D=0Ato the intended recipient at the e-mail address to which it ha=
s been=20=0D=0Aaddressed. It may not be disclosed or used by any other tha=
n that addressee.=0D=0AIf you are not the intended recipient you are reques=
ted to preserve this=20=0D=0Aconfidentiality and you must not use, disclose=
, copy, print or rely on this=20=0D=0Ae-mail in any way. Please notify post=
ma...@sc... quoting the=20=0D=0Aname of the sender and delete th=
e email from your system.=0D=0A=0D=0AAlthough SCRI has taken reasonable pre=
cautions to ensure no viruses are=20=0D=0Apresent in this email, neither th=
e Institute nor the sender accepts any=20=0D=0Aresponsibility for any virus=
es, and it is your responsibility to scan the email=20=0D=0Aand the attachm=
ents (if any).=0D=0A
From: Matt N. <new...@ca...> - 2005年03月25日 04:50:21
Hi Leighton,
> The Loop method and custom event methods work fine on Windows. 
> On Linux, they dynamically update the plot, but not the button
> label. On OS X, they do nothing, and only appear to update
> the plot after the loops end.
 
I'm no expert in wxPython or matplotlib, but there are a few
possible problems with your script:
 - For the timing method, I think the issue is simply how fast 
 you can send Timer events. You're doing them every 20ms, 
 which is pretty fast (I'm willing to take the blame for 
 sending you an example that goes that fast!). If you change 
 that to 200ms, I'll bet you will see more updates. 
 - The Loop method runs a for-loop which may not allow other wx
 events to be processed, such as changing a Button label.
 - The Custom Event uses a python for-loop, so I think it's not
 very different from the Loop method in that it's liable to
 drop events.
For all these, I would think that adding
 self.Update()
should help. This is supposed to repaint the whole wxWidget. 
That will take time, but should really update all widgets. But
it seems that this is not foolproof, and that it can lose
events: I don't know why this is.
> Matt's solution works on OS X, but I'm afraid I didn't specify
> what my goal was particularly well. I'm aiming to dynamically
> update a matplotlib plot embedded within a wx.Panel (or
> wx.Frame) from another object, whose internal state is
> changing so that the calling object's internal state is
> reflected in the matplotlib plot. The wx.Timer solution
> doesn't seem appropriate for that (though if I'm wrong, I'm
> happy to take advice).
> 
> After some reading around, I worked up two alternatives for
> updating the plot from another object.
> 
> 1) wx.Timer, as per Matt
> 2) Loop, and pass the value of the loop counter
> 3) A custom wx event, bound to the update method
I think you want to avoid the Loop method, as it can block other
widget events. I believe that what you want is to replot the
figure when (a) the data has changed and (b) some minimum time
has elapsed since the last drawing. One approach is to use a
timer to periodically check (this sets the minimun time) for new
data, and redraw the plot when there's new data.
Another approach is to trigger on changes in the data, possibly
saving the timestamp when a redraw is done so as to not draw too
often. Which method to use probably depends on how easily it is
to detect and act upon changes to the data. Finally, you may
also consider putting the data-intensive code in a separate
thread from the GUI.
But I think the main issue is to not try to redraw the plot 50
times per second. ;).
Hope that helps,
--Matt

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