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
(16) |
2
(8) |
3
(4) |
4
|
5
|
6
(3) |
7
(11) |
8
(16) |
9
(1) |
10
(2) |
11
(2) |
12
(6) |
13
(2) |
14
(4) |
15
(5) |
16
(10) |
17
(5) |
18
|
19
|
20
|
21
(3) |
22
|
23
(12) |
24
(7) |
25
(1) |
26
|
27
(3) |
28
(4) |
29
(5) |
30
(2) |
|
|
The 'animated' property is used _deep_ with in `axes.draw` ( https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_base.py#L2035) to skip artists with the 'animated' flag set. This makes them play nice with blitting (which explicitly uses `axes.draw_artist`) so they are not drawn on a call to `ax.draw` (which sets up the background canvas). Sorry, I should not have included them with out a good explanation, I was feeling too fancy with that example. Tom On Thu, Apr 16, 2015 at 11:27 AM Ryan Nelson <rne...@gm...> wrote: > Ben, > > Sorry. I probably should have just dropped that entirely. In my code > sample, it is actually commented out because it breaks the animation with > the nbagg backend. It was in Tom's example, so I left it in because I > wanted to find out what it was doing. > > Ryan > > On Thu, Apr 16, 2015 at 9:30 AM, Benjamin Root <ben...@ou...> wrote: > >> I just noticed your use of "animated=True". I have had trouble using that >> in the past with the animation module. It is a leftover from the days >> before the animation module and isn't actually used by it, IIRC. Try not >> supplying that argument. >> >> On Thu, Apr 16, 2015 at 8:18 AM, Ryan Nelson <rne...@gm...> >> wrote: >> >>> Tom, >>> >>> Thanks for the code. As it was given, I had to change `blit=True` in the >>> `FuncAnimation` call in order to get this to work in a regular Qt backend. >>> It did not work with the nbagg backend; however, if I used this code it >>> works fine: >>> #### >>> %matplotlib nbagg >>> >>> import numpy as np >>> import matplotlib.pyplot as plt >>> import matplotlib.animation as animate >>> >>> class Testing(object): >>> def __init__(self, ): >>> self.fig = plt.figure() >>> array = np.random.rand(4,5) >>> array = np.zeros((4,5)) >>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.)#, >>> animated=True) >>> self.pc.set_clim([0, 1]) >>> self.points = [plt.scatter(np.random.rand(), >>> np.random.rand())]#, animated=True)] >>> >>> def update(self, iter_num): >>> array = np.random.rand(4*5) >>> self.pc.set_array(array) >>> for point in self.points: >>> point.set_offsets([np.random.rand(), np.random.rand()]) >>> #return (self.pc, ) + tuple(self.points) >>> >>> >>> test = Testing() >>> ani = animate.FuncAnimation(test.fig, test.update, interval=250, >>> blit=False, frames=50) >>> plt.show() >>> #### >>> Also this code solves the problem I was having with several scatter >>> points being displayed upon multiple runs of the same code cell. >>> >>> I wasn't familiar with the "animated" keyword, and it is not well >>> documented yet. Can you give me a quick explanation of what it is doing? >>> >>> Ben: thanks for the hint about the _stop() method. I might look into >>> that for my example. >>> >>> Thank you all for your assistance. Things are working pretty much as I >>> need now! >>> >>> Ryan >>> >>> On Sun, Apr 12, 2015 at 9:24 AM, Thomas Caswell <tca...@gm...> >>> wrote: >>> >>>> You can >>>> >>>> >>>> ``` >>>> >>>> #import matplotlib >>>> >>>> #matplotlib.use('nbagg') >>>> >>>> #%matplotlib nbagg >>>> >>>> import numpy as np >>>> >>>> import matplotlib.pyplot as plt >>>> >>>> import matplotlib.animation as animate >>>> >>>> >>>> class Testing(object): >>>> >>>> def __init__(self, ): >>>> >>>> self.fig = plt.figure() >>>> >>>> array = np.random.rand(4,5) >>>> >>>> array = np.zeros((4,5)) >>>> >>>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1., >>>> animated=True) >>>> >>>> self.pc.set_clim([0, 1]) >>>> >>>> self.points = [plt.scatter(np.random.rand(), np.random.rand(), >>>> animated=True)] >>>> >>>> >>>> def update(self, iter_num): >>>> >>>> array = np.random.rand(4*5) >>>> >>>> self.pc.set_array(array) >>>> >>>> for point in self.points: >>>> >>>> point.set_offsets([np.random.rand(), np.random.rand()]) >>>> >>>> >>>> return (self.pc, ) + tuple(self.points) >>>> >>>> >>>> >>>> test = Testing() >>>> >>>> ani = animate.FuncAnimation(test.fig, test.update, interval=10, >>>> blit=False, frames=50) >>>> >>>> plt.show() >>>> >>>> ``` >>>> >>>> note the addition of the `set_clim` line in the `__init__` method. >>>> >>>> >>>> You can also update the scatter artist in-place. The other changes >>>> will make it a bit for performant if you use bliting (which does not work >>>> with nbagg currently) >>>> >>>> Sorry I missed that part of the question first time through. >>>> >>>> Tom >>>> >>>> On Sun, Apr 12, 2015, 08:31 Ryan Nelson <rne...@gm...> wrote: >>>> >>>>> Tom, >>>>> >>>>> Thanks for the links. It does seem like fragments of my problem are >>>>> addressed in each of those comments, so I guess I'll have to wait for a bit >>>>> until those things get resolved. For now, I can just tell my students to >>>>> restart the IPython kernel each time they run the animation, which isn't >>>>> that hard. It's too bad that there isn't a 'stop' method now, but it's good >>>>> to hear that it isn't a completely terrible idea. >>>>> >>>>> I do still need help with Question #3 from my original email, though, >>>>> because it affects both the Qt and nbagg backends, and it is a bit of a >>>>> show stopper. I can't quite understand why initializing a pcolor(mesh) with >>>>> random numbers makes it possible to update the array in an animation, but >>>>> if you use all zeros or ones, it seems to be immutable. >>>>> >>>>> Ryan >>>>> >>>>> On Sat, Apr 11, 2015 at 8:35 PM, Thomas Caswell <tca...@gm...> >>>>> wrote: >>>>> >>>>>> Ryan, >>>>>> >>>>>> I have not looked at your exact issue yet, but there seems to be some >>>>>> underlying issues with animation and nbagg which we have not tracked down >>>>>> yet. See: >>>>>> >>>>>> https://github.com/matplotlib/matplotlib/pull/4290 >>>>>> https://github.com/matplotlib/matplotlib/issues/4287 >>>>>> https://github.com/matplotlib/matplotlib/issues/4288 >>>>>> >>>>>> Running until a given condition is an interesting idea, but I think >>>>>> that means the animation objects needs to have a public 'stop' method first! >>>>>> >>>>>> Tom >>>>>> >>>>>> On Fri, Apr 10, 2015 at 3:00 PM Ryan Nelson <rne...@gm...> >>>>>> wrote: >>>>>> >>>>>>> Good afternoon, all! >>>>>>> >>>>>>> I'm really digging the nbagg backend, and I'm trying to use it to >>>>>>> make an animation. As the subject suggests, though, I'm having some issues >>>>>>> with these features. I'm using Python 3.4, Matplotlib 1.4.3, and IPython >>>>>>> 3.1. Below is a small code sample that emulates my system. The pcolor call >>>>>>> can be substituted for pcolormesh, and I see the same behavior. (Sorry this >>>>>>> is a bit long. I tried to break it up as best as possible.) >>>>>>> >>>>>>> ############# >>>>>>> #import matplotlib >>>>>>> #matplotlib.use('nbagg') >>>>>>> #%matplotlib nbagg >>>>>>> import numpy as np >>>>>>> import matplotlib.pyplot as plt >>>>>>> import matplotlib.animation as animate >>>>>>> >>>>>>> class Testing(object): >>>>>>> def __init__(self, ): >>>>>>> self.fig = plt.figure() >>>>>>> array = np.random.rand(4,5) >>>>>>> #array = np.zeros((4,5)) >>>>>>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.) >>>>>>> self.points = [plt.scatter(np.random.rand(), >>>>>>> np.random.rand())] >>>>>>> >>>>>>> def update(self, iter_num): >>>>>>> array = np.random.rand(4*5) >>>>>>> self.pc.set_array(array) >>>>>>> for point in self.points: >>>>>>> point.remove() >>>>>>> self.points = [plt.scatter(np.random.rand(), >>>>>>> np.random.rand())] >>>>>>> >>>>>>> test = Testing() >>>>>>> animate.FuncAnimation(test.fig, test.update, interval=1000, >>>>>>> blit=False) >>>>>>> plt.show() >>>>>>> ############### >>>>>>> >>>>>>> 1. As is, this code runs fine with a Qt backend. It also runs fine >>>>>>> as a first call in a notebook if the `show` call is commented out and the >>>>>>> `%matplotlib` line is uncommented. However, if the `show` call is left in >>>>>>> and the `matplotlib.use` call is uncommented, then the pcolor array >>>>>>> changes, but the scatterpoint only shows on the first update and then >>>>>>> disappears forever. What is the difference between these two invocations? >>>>>>> >>>>>>> 2. With the `%matplotlib` magic uncommented and `show` removed, the >>>>>>> first invocation of this as a cell works fine. Closing the figure (with the >>>>>>> red X) and running the cell again shows two scatter plot points. Running it >>>>>>> a third time shows three scatter plot points. If you call `plt.clf` in the >>>>>>> next cell, I get a series of errors as follows: >>>>>>> _____ >>>>>>> ERROR:tornado.application:Exception in callback <bound method >>>>>>> TimerTornado._on_timer of <matplotlib.backends.backend_nbagg.TimerTornado >>>>>>> object at 0x7f894cb10f98>> >>>>>>> Traceback (most recent call last): >>>>>>> File "/usr/lib64/python3.4/site-packages/tornado/ioloop.py", line >>>>>>> 976, in _run >>>>>>> return self.callback() >>>>>>> File >>>>>>> "/usr/lib64/python3.4/site-packages/matplotlib/backend_bases.py", line >>>>>>> 1290, in _on_timer >>>>>>> ret = func(*args, **kwargs) >>>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>>> line 925, in _step >>>>>>> still_going = Animation._step(self, *args) >>>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>>> line 784, in _step >>>>>>> self._draw_next_frame(framedata, self._blit) >>>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>>> line 803, in _draw_next_frame >>>>>>> self._draw_frame(framedata) >>>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>>> line 1106, in _draw_frame >>>>>>> self._drawn_artists = self._func(framedata, *self._args) >>>>>>> File "<ipython-input-2-f9290d8f6154>", line 22, in update >>>>>>> point.remove() >>>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/artist.py", >>>>>>> line 139, in remove >>>>>>> self._remove_method(self) >>>>>>> File >>>>>>> "/usr/lib64/python3.4/site-packages/matplotlib/axes/_base.py", line 1479, >>>>>>> in <lambda> >>>>>>> collection._remove_method = lambda h: self.collections.remove(h) >>>>>>> ValueError: list.remove(x): x not in list >>>>>>> ______ >>>>>>> Why does this happen? Is there a way to close the animation cleanly? >>>>>>> >>>>>>> 3. If I uncomment the `np.zeros` call, the pcolor array never >>>>>>> updates irrespective of the backend. I see the same behavior with `np.ones` >>>>>>> as well, even if the dtype is set to `float`. Is there are a way to start >>>>>>> with a all-zero pcolor that allow dynamic updates? >>>>>>> >>>>>>> 4. I'd like to be able to have the animation run until a certain >>>>>>> condition is met. Is there a way to code a clean break for the animation? >>>>>>> >>>>>>> >>>>>>> As always, any help is most appreciated! >>>>>>> >>>>>>> Ryan >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------------ >>>>>>> ------------------ >>>>>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >>>>>>> Develop your own process in accordance with the BPMN 2 standard >>>>>>> Learn Process modeling best practices with Bonita BPM through live >>>>>>> exercises >>>>>>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >>>>>>> event?utm_ >>>>>>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_ >>>>>>> campaign=VA_SF_______________________________________________ >>>>>>> Matplotlib-users mailing list >>>>>>> Mat...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>>> >>>>>> >>>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >>> Develop your own process in accordance with the BPMN 2 standard >>> Learn Process modeling best practices with Bonita BPM through live >>> exercises >>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >>> event?utm_ >>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >
Oops. I meant bits not bytes in my earlier statements. Sorry. On Thu, Apr 16, 2015 at 11:24 AM, Ryan Nelson <rne...@gm...> wrote: > xnview says it is 128*128*8, but "print >> imread('python-gray.png').shape" says (128, 128, 3), however I suppose >> it should be (128, 128)! > > Not sure that this is true, but I guess that xnview is using the third > dimension here to refer to a number of bytes. In this case, it is two > bytes, one for the black/white level and the other for alpha level. When > you import this with imread, the png is converted into a Numpy array. The > default behavior in this case is to create an array which is 128*128*3 > because the third dimmension is the (R,G,B) levels, which will all be equal > for a gray scale image. This behavior is probably intentional so that you > don't have to write different code to handle gray/color images. > > For python-color.png, it is my fault. xnview says it is 128*128*32, so >> it has alpha channel. Hence "imread().shape =(128, 128, 4)" is right > > If the third dimension from xnview is bytes, then yes, you are correct. > > btw. imread return array which has value between 0 and 1 for PNG file. >> But for other picture format, the value is 0~255. The manual says >> matplotlib reads PNG only by it self, and other files via PIL.But I >> think it is better to make the returned array consistent. > > That is most likely due to the way that PNG and e.g. older JPG are > defined. PNG defines each RGBA value using float32, while older JPG uses > uint8. Therefor, it would not make sense to change the dtype of the image > on import. > > Hope that helps. > Ryan > > > > > On Thu, Apr 16, 2015 at 10:51 AM, oyster <lep...@gm...> wrote: > >> Firstly, thanks, Fabrice Silva >> >> I have checked my picture files again. >> >> For python-gray.png, now it is attacched here or can be downloaded >> from >> http://bbs.blendercn.org/data/attachment/forum/201504/16/222351w3952n3o9968m9a5.png >> . >> xnview says it is 128*128*8, but "print >> imread('python-gray.png').shape" says (128, 128, 3), however I suppose >> it should be (128, 128)! >> >> For python-color.png, it is my fault. xnview says it is 128*128*32, so >> it has alpha channel. Hence "imread().shape =(128, 128, 4)" is right >> >> btw. imread return array which has value between 0 and 1 for PNG file. >> But for other picture format, the value is 0~255. The manual says >> matplotlib reads PNG only by it self, and other files via PIL.But I >> think it is better to make the returned array consistent. >> >> >> ------------------------------------------------------------------------------ >> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >> Develop your own process in accordance with the BPMN 2 standard >> Learn Process modeling best practices with Bonita BPM through live >> exercises >> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >> event?utm_ >> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >
Ben, Sorry. I probably should have just dropped that entirely. In my code sample, it is actually commented out because it breaks the animation with the nbagg backend. It was in Tom's example, so I left it in because I wanted to find out what it was doing. Ryan On Thu, Apr 16, 2015 at 9:30 AM, Benjamin Root <ben...@ou...> wrote: > I just noticed your use of "animated=True". I have had trouble using that > in the past with the animation module. It is a leftover from the days > before the animation module and isn't actually used by it, IIRC. Try not > supplying that argument. > > On Thu, Apr 16, 2015 at 8:18 AM, Ryan Nelson <rne...@gm...> > wrote: > >> Tom, >> >> Thanks for the code. As it was given, I had to change `blit=True` in the >> `FuncAnimation` call in order to get this to work in a regular Qt backend. >> It did not work with the nbagg backend; however, if I used this code it >> works fine: >> #### >> %matplotlib nbagg >> >> import numpy as np >> import matplotlib.pyplot as plt >> import matplotlib.animation as animate >> >> class Testing(object): >> def __init__(self, ): >> self.fig = plt.figure() >> array = np.random.rand(4,5) >> array = np.zeros((4,5)) >> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.)#, >> animated=True) >> self.pc.set_clim([0, 1]) >> self.points = [plt.scatter(np.random.rand(), np.random.rand())]#, >> animated=True)] >> >> def update(self, iter_num): >> array = np.random.rand(4*5) >> self.pc.set_array(array) >> for point in self.points: >> point.set_offsets([np.random.rand(), np.random.rand()]) >> #return (self.pc, ) + tuple(self.points) >> >> >> test = Testing() >> ani = animate.FuncAnimation(test.fig, test.update, interval=250, >> blit=False, frames=50) >> plt.show() >> #### >> Also this code solves the problem I was having with several scatter >> points being displayed upon multiple runs of the same code cell. >> >> I wasn't familiar with the "animated" keyword, and it is not well >> documented yet. Can you give me a quick explanation of what it is doing? >> >> Ben: thanks for the hint about the _stop() method. I might look into that >> for my example. >> >> Thank you all for your assistance. Things are working pretty much as I >> need now! >> >> Ryan >> >> On Sun, Apr 12, 2015 at 9:24 AM, Thomas Caswell <tca...@gm...> >> wrote: >> >>> You can >>> >>> >>> ``` >>> >>> #import matplotlib >>> >>> #matplotlib.use('nbagg') >>> >>> #%matplotlib nbagg >>> >>> import numpy as np >>> >>> import matplotlib.pyplot as plt >>> >>> import matplotlib.animation as animate >>> >>> >>> class Testing(object): >>> >>> def __init__(self, ): >>> >>> self.fig = plt.figure() >>> >>> array = np.random.rand(4,5) >>> >>> array = np.zeros((4,5)) >>> >>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1., >>> animated=True) >>> >>> self.pc.set_clim([0, 1]) >>> >>> self.points = [plt.scatter(np.random.rand(), np.random.rand(), >>> animated=True)] >>> >>> >>> def update(self, iter_num): >>> >>> array = np.random.rand(4*5) >>> >>> self.pc.set_array(array) >>> >>> for point in self.points: >>> >>> point.set_offsets([np.random.rand(), np.random.rand()]) >>> >>> >>> return (self.pc, ) + tuple(self.points) >>> >>> >>> >>> test = Testing() >>> >>> ani = animate.FuncAnimation(test.fig, test.update, interval=10, >>> blit=False, frames=50) >>> >>> plt.show() >>> >>> ``` >>> >>> note the addition of the `set_clim` line in the `__init__` method. >>> >>> >>> You can also update the scatter artist in-place. The other changes will >>> make it a bit for performant if you use bliting (which does not work with >>> nbagg currently) >>> >>> Sorry I missed that part of the question first time through. >>> >>> Tom >>> >>> On Sun, Apr 12, 2015, 08:31 Ryan Nelson <rne...@gm...> wrote: >>> >>>> Tom, >>>> >>>> Thanks for the links. It does seem like fragments of my problem are >>>> addressed in each of those comments, so I guess I'll have to wait for a bit >>>> until those things get resolved. For now, I can just tell my students to >>>> restart the IPython kernel each time they run the animation, which isn't >>>> that hard. It's too bad that there isn't a 'stop' method now, but it's good >>>> to hear that it isn't a completely terrible idea. >>>> >>>> I do still need help with Question #3 from my original email, though, >>>> because it affects both the Qt and nbagg backends, and it is a bit of a >>>> show stopper. I can't quite understand why initializing a pcolor(mesh) with >>>> random numbers makes it possible to update the array in an animation, but >>>> if you use all zeros or ones, it seems to be immutable. >>>> >>>> Ryan >>>> >>>> On Sat, Apr 11, 2015 at 8:35 PM, Thomas Caswell <tca...@gm...> >>>> wrote: >>>> >>>>> Ryan, >>>>> >>>>> I have not looked at your exact issue yet, but there seems to be some >>>>> underlying issues with animation and nbagg which we have not tracked down >>>>> yet. See: >>>>> >>>>> https://github.com/matplotlib/matplotlib/pull/4290 >>>>> https://github.com/matplotlib/matplotlib/issues/4287 >>>>> https://github.com/matplotlib/matplotlib/issues/4288 >>>>> >>>>> Running until a given condition is an interesting idea, but I think >>>>> that means the animation objects needs to have a public 'stop' method first! >>>>> >>>>> Tom >>>>> >>>>> On Fri, Apr 10, 2015 at 3:00 PM Ryan Nelson <rne...@gm...> >>>>> wrote: >>>>> >>>>>> Good afternoon, all! >>>>>> >>>>>> I'm really digging the nbagg backend, and I'm trying to use it to >>>>>> make an animation. As the subject suggests, though, I'm having some issues >>>>>> with these features. I'm using Python 3.4, Matplotlib 1.4.3, and IPython >>>>>> 3.1. Below is a small code sample that emulates my system. The pcolor call >>>>>> can be substituted for pcolormesh, and I see the same behavior. (Sorry this >>>>>> is a bit long. I tried to break it up as best as possible.) >>>>>> >>>>>> ############# >>>>>> #import matplotlib >>>>>> #matplotlib.use('nbagg') >>>>>> #%matplotlib nbagg >>>>>> import numpy as np >>>>>> import matplotlib.pyplot as plt >>>>>> import matplotlib.animation as animate >>>>>> >>>>>> class Testing(object): >>>>>> def __init__(self, ): >>>>>> self.fig = plt.figure() >>>>>> array = np.random.rand(4,5) >>>>>> #array = np.zeros((4,5)) >>>>>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.) >>>>>> self.points = [plt.scatter(np.random.rand(), >>>>>> np.random.rand())] >>>>>> >>>>>> def update(self, iter_num): >>>>>> array = np.random.rand(4*5) >>>>>> self.pc.set_array(array) >>>>>> for point in self.points: >>>>>> point.remove() >>>>>> self.points = [plt.scatter(np.random.rand(), >>>>>> np.random.rand())] >>>>>> >>>>>> test = Testing() >>>>>> animate.FuncAnimation(test.fig, test.update, interval=1000, >>>>>> blit=False) >>>>>> plt.show() >>>>>> ############### >>>>>> >>>>>> 1. As is, this code runs fine with a Qt backend. It also runs fine as >>>>>> a first call in a notebook if the `show` call is commented out and the >>>>>> `%matplotlib` line is uncommented. However, if the `show` call is left in >>>>>> and the `matplotlib.use` call is uncommented, then the pcolor array >>>>>> changes, but the scatterpoint only shows on the first update and then >>>>>> disappears forever. What is the difference between these two invocations? >>>>>> >>>>>> 2. With the `%matplotlib` magic uncommented and `show` removed, the >>>>>> first invocation of this as a cell works fine. Closing the figure (with the >>>>>> red X) and running the cell again shows two scatter plot points. Running it >>>>>> a third time shows three scatter plot points. If you call `plt.clf` in the >>>>>> next cell, I get a series of errors as follows: >>>>>> _____ >>>>>> ERROR:tornado.application:Exception in callback <bound method >>>>>> TimerTornado._on_timer of <matplotlib.backends.backend_nbagg.TimerTornado >>>>>> object at 0x7f894cb10f98>> >>>>>> Traceback (most recent call last): >>>>>> File "/usr/lib64/python3.4/site-packages/tornado/ioloop.py", line >>>>>> 976, in _run >>>>>> return self.callback() >>>>>> File >>>>>> "/usr/lib64/python3.4/site-packages/matplotlib/backend_bases.py", line >>>>>> 1290, in _on_timer >>>>>> ret = func(*args, **kwargs) >>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>> line 925, in _step >>>>>> still_going = Animation._step(self, *args) >>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>> line 784, in _step >>>>>> self._draw_next_frame(framedata, self._blit) >>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>> line 803, in _draw_next_frame >>>>>> self._draw_frame(framedata) >>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>>> line 1106, in _draw_frame >>>>>> self._drawn_artists = self._func(framedata, *self._args) >>>>>> File "<ipython-input-2-f9290d8f6154>", line 22, in update >>>>>> point.remove() >>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/artist.py", >>>>>> line 139, in remove >>>>>> self._remove_method(self) >>>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/axes/_base.py", >>>>>> line 1479, in <lambda> >>>>>> collection._remove_method = lambda h: self.collections.remove(h) >>>>>> ValueError: list.remove(x): x not in list >>>>>> ______ >>>>>> Why does this happen? Is there a way to close the animation cleanly? >>>>>> >>>>>> 3. If I uncomment the `np.zeros` call, the pcolor array never updates >>>>>> irrespective of the backend. I see the same behavior with `np.ones` as >>>>>> well, even if the dtype is set to `float`. Is there are a way to start with >>>>>> a all-zero pcolor that allow dynamic updates? >>>>>> >>>>>> 4. I'd like to be able to have the animation run until a certain >>>>>> condition is met. Is there a way to code a clean break for the animation? >>>>>> >>>>>> >>>>>> As always, any help is most appreciated! >>>>>> >>>>>> Ryan >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------------ >>>>>> ------------------ >>>>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >>>>>> Develop your own process in accordance with the BPMN 2 standard >>>>>> Learn Process modeling best practices with Bonita BPM through live >>>>>> exercises >>>>>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >>>>>> event?utm_ >>>>>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_ >>>>>> campaign=VA_SF_______________________________________________ >>>>>> Matplotlib-users mailing list >>>>>> Mat...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>> >>>>> >>>> >> >> >> ------------------------------------------------------------------------------ >> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >> Develop your own process in accordance with the BPMN 2 standard >> Learn Process modeling best practices with Bonita BPM through live >> exercises >> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >> event?utm_ >> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >
> > xnview says it is 128*128*8, but "print > imread('python-gray.png').shape" says (128, 128, 3), however I suppose > it should be (128, 128)! Not sure that this is true, but I guess that xnview is using the third dimension here to refer to a number of bytes. In this case, it is two bytes, one for the black/white level and the other for alpha level. When you import this with imread, the png is converted into a Numpy array. The default behavior in this case is to create an array which is 128*128*3 because the third dimmension is the (R,G,B) levels, which will all be equal for a gray scale image. This behavior is probably intentional so that you don't have to write different code to handle gray/color images. For python-color.png, it is my fault. xnview says it is 128*128*32, so > it has alpha channel. Hence "imread().shape =(128, 128, 4)" is right If the third dimension from xnview is bytes, then yes, you are correct. btw. imread return array which has value between 0 and 1 for PNG file. > But for other picture format, the value is 0~255. The manual says > matplotlib reads PNG only by it self, and other files via PIL.But I > think it is better to make the returned array consistent. That is most likely due to the way that PNG and e.g. older JPG are defined. PNG defines each RGBA value using float32, while older JPG uses uint8. Therefor, it would not make sense to change the dtype of the image on import. Hope that helps. Ryan On Thu, Apr 16, 2015 at 10:51 AM, oyster <lep...@gm...> wrote: > Firstly, thanks, Fabrice Silva > > I have checked my picture files again. > > For python-gray.png, now it is attacched here or can be downloaded > from > http://bbs.blendercn.org/data/attachment/forum/201504/16/222351w3952n3o9968m9a5.png > . > xnview says it is 128*128*8, but "print > imread('python-gray.png').shape" says (128, 128, 3), however I suppose > it should be (128, 128)! > > For python-color.png, it is my fault. xnview says it is 128*128*32, so > it has alpha channel. Hence "imread().shape =(128, 128, 4)" is right > > btw. imread return array which has value between 0 and 1 for PNG file. > But for other picture format, the value is 0~255. The manual says > matplotlib reads PNG only by it self, and other files via PIL.But I > think it is better to make the returned array consistent. > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
Le jeudi 16 avril 2015, oyster a écrit : > Firstly, thanks, Fabrice Silva > > I have checked my picture files again. > > For python-gray.png, now it is attacched here or can be downloaded > from http://bbs.blendercn.org/data/attachment/forum/201504/16/222351w3952n3o9968m9a5.png. > xnview says it is 128*128*8, but "print > imread('python-gray.png').shape" says (128, 128, 3), however I suppose > it should be (128, 128)! Funnily (or not), the png is in fact 8-bits depth so you could infer it is grayscale, but matplotlib is right : your file uses a color palette. The 8-bits values refer to indices of the 256-length color palette. These indices are then converted back to the colorspace, so the shape is eventually (...,3). Unfortunately, the color palette is here the grayscale... -- Fabrice
Firstly, thanks, Fabrice Silva I have checked my picture files again. For python-gray.png, now it is attacched here or can be downloaded from http://bbs.blendercn.org/data/attachment/forum/201504/16/222351w3952n3o9968m9a5.png. xnview says it is 128*128*8, but "print imread('python-gray.png').shape" says (128, 128, 3), however I suppose it should be (128, 128)! For python-color.png, it is my fault. xnview says it is 128*128*32, so it has alpha channel. Hence "imread().shape =(128, 128, 4)" is right btw. imread return array which has value between 0 and 1 for PNG file. But for other picture format, the value is 0~255. The manual says matplotlib reads PNG only by it self, and other files via PIL.But I think it is better to make the returned array consistent.
That will be up to him. The only reason why I know about the work is because our publisher wanted to make sure that our two books didn't cover the same material. He isn't a regular on the mailing list, so I don't know if he even would see this message. I'll let him know that there is interest. Ben Root On Wed, Apr 15, 2015 at 9:16 PM, Chris O'Halloran <cm...@gm...> wrote: > On 16 April 2015 at 09:51, Benjamin Root <ben...@ou...> wrote: > >> A little birdie has told me that someone else is writing a new >> comprehensive matplotlib book (I think it would replace Sandros' book). >> Last I heard from the birdie, he was most of the way done with the >> manuscript. Based on my experience with the edit/review process, I would >> guess 2-3 more months to see it finished and published. >> >> > Oh cool. I'll look out for this. Will it be advertised on this list? > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
I just noticed your use of "animated=True". I have had trouble using that in the past with the animation module. It is a leftover from the days before the animation module and isn't actually used by it, IIRC. Try not supplying that argument. On Thu, Apr 16, 2015 at 8:18 AM, Ryan Nelson <rne...@gm...> wrote: > Tom, > > Thanks for the code. As it was given, I had to change `blit=True` in the > `FuncAnimation` call in order to get this to work in a regular Qt backend. > It did not work with the nbagg backend; however, if I used this code it > works fine: > #### > %matplotlib nbagg > > import numpy as np > import matplotlib.pyplot as plt > import matplotlib.animation as animate > > class Testing(object): > def __init__(self, ): > self.fig = plt.figure() > array = np.random.rand(4,5) > array = np.zeros((4,5)) > self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.)#, > animated=True) > self.pc.set_clim([0, 1]) > self.points = [plt.scatter(np.random.rand(), np.random.rand())]#, > animated=True)] > > def update(self, iter_num): > array = np.random.rand(4*5) > self.pc.set_array(array) > for point in self.points: > point.set_offsets([np.random.rand(), np.random.rand()]) > #return (self.pc, ) + tuple(self.points) > > > test = Testing() > ani = animate.FuncAnimation(test.fig, test.update, interval=250, > blit=False, frames=50) > plt.show() > #### > Also this code solves the problem I was having with several scatter points > being displayed upon multiple runs of the same code cell. > > I wasn't familiar with the "animated" keyword, and it is not well > documented yet. Can you give me a quick explanation of what it is doing? > > Ben: thanks for the hint about the _stop() method. I might look into that > for my example. > > Thank you all for your assistance. Things are working pretty much as I > need now! > > Ryan > > On Sun, Apr 12, 2015 at 9:24 AM, Thomas Caswell <tca...@gm...> > wrote: > >> You can >> >> >> ``` >> >> #import matplotlib >> >> #matplotlib.use('nbagg') >> >> #%matplotlib nbagg >> >> import numpy as np >> >> import matplotlib.pyplot as plt >> >> import matplotlib.animation as animate >> >> >> class Testing(object): >> >> def __init__(self, ): >> >> self.fig = plt.figure() >> >> array = np.random.rand(4,5) >> >> array = np.zeros((4,5)) >> >> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1., >> animated=True) >> >> self.pc.set_clim([0, 1]) >> >> self.points = [plt.scatter(np.random.rand(), np.random.rand(), >> animated=True)] >> >> >> def update(self, iter_num): >> >> array = np.random.rand(4*5) >> >> self.pc.set_array(array) >> >> for point in self.points: >> >> point.set_offsets([np.random.rand(), np.random.rand()]) >> >> >> return (self.pc, ) + tuple(self.points) >> >> >> >> test = Testing() >> >> ani = animate.FuncAnimation(test.fig, test.update, interval=10, >> blit=False, frames=50) >> >> plt.show() >> >> ``` >> >> note the addition of the `set_clim` line in the `__init__` method. >> >> >> You can also update the scatter artist in-place. The other changes will >> make it a bit for performant if you use bliting (which does not work with >> nbagg currently) >> >> Sorry I missed that part of the question first time through. >> >> Tom >> >> On Sun, Apr 12, 2015, 08:31 Ryan Nelson <rne...@gm...> wrote: >> >>> Tom, >>> >>> Thanks for the links. It does seem like fragments of my problem are >>> addressed in each of those comments, so I guess I'll have to wait for a bit >>> until those things get resolved. For now, I can just tell my students to >>> restart the IPython kernel each time they run the animation, which isn't >>> that hard. It's too bad that there isn't a 'stop' method now, but it's good >>> to hear that it isn't a completely terrible idea. >>> >>> I do still need help with Question #3 from my original email, though, >>> because it affects both the Qt and nbagg backends, and it is a bit of a >>> show stopper. I can't quite understand why initializing a pcolor(mesh) with >>> random numbers makes it possible to update the array in an animation, but >>> if you use all zeros or ones, it seems to be immutable. >>> >>> Ryan >>> >>> On Sat, Apr 11, 2015 at 8:35 PM, Thomas Caswell <tca...@gm...> >>> wrote: >>> >>>> Ryan, >>>> >>>> I have not looked at your exact issue yet, but there seems to be some >>>> underlying issues with animation and nbagg which we have not tracked down >>>> yet. See: >>>> >>>> https://github.com/matplotlib/matplotlib/pull/4290 >>>> https://github.com/matplotlib/matplotlib/issues/4287 >>>> https://github.com/matplotlib/matplotlib/issues/4288 >>>> >>>> Running until a given condition is an interesting idea, but I think >>>> that means the animation objects needs to have a public 'stop' method first! >>>> >>>> Tom >>>> >>>> On Fri, Apr 10, 2015 at 3:00 PM Ryan Nelson <rne...@gm...> >>>> wrote: >>>> >>>>> Good afternoon, all! >>>>> >>>>> I'm really digging the nbagg backend, and I'm trying to use it to make >>>>> an animation. As the subject suggests, though, I'm having some issues with >>>>> these features. I'm using Python 3.4, Matplotlib 1.4.3, and IPython 3.1. >>>>> Below is a small code sample that emulates my system. The pcolor call can >>>>> be substituted for pcolormesh, and I see the same behavior. (Sorry this is >>>>> a bit long. I tried to break it up as best as possible.) >>>>> >>>>> ############# >>>>> #import matplotlib >>>>> #matplotlib.use('nbagg') >>>>> #%matplotlib nbagg >>>>> import numpy as np >>>>> import matplotlib.pyplot as plt >>>>> import matplotlib.animation as animate >>>>> >>>>> class Testing(object): >>>>> def __init__(self, ): >>>>> self.fig = plt.figure() >>>>> array = np.random.rand(4,5) >>>>> #array = np.zeros((4,5)) >>>>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.) >>>>> self.points = [plt.scatter(np.random.rand(), np.random.rand())] >>>>> >>>>> def update(self, iter_num): >>>>> array = np.random.rand(4*5) >>>>> self.pc.set_array(array) >>>>> for point in self.points: >>>>> point.remove() >>>>> self.points = [plt.scatter(np.random.rand(), np.random.rand())] >>>>> >>>>> test = Testing() >>>>> animate.FuncAnimation(test.fig, test.update, interval=1000, blit=False) >>>>> plt.show() >>>>> ############### >>>>> >>>>> 1. As is, this code runs fine with a Qt backend. It also runs fine as >>>>> a first call in a notebook if the `show` call is commented out and the >>>>> `%matplotlib` line is uncommented. However, if the `show` call is left in >>>>> and the `matplotlib.use` call is uncommented, then the pcolor array >>>>> changes, but the scatterpoint only shows on the first update and then >>>>> disappears forever. What is the difference between these two invocations? >>>>> >>>>> 2. With the `%matplotlib` magic uncommented and `show` removed, the >>>>> first invocation of this as a cell works fine. Closing the figure (with the >>>>> red X) and running the cell again shows two scatter plot points. Running it >>>>> a third time shows three scatter plot points. If you call `plt.clf` in the >>>>> next cell, I get a series of errors as follows: >>>>> _____ >>>>> ERROR:tornado.application:Exception in callback <bound method >>>>> TimerTornado._on_timer of <matplotlib.backends.backend_nbagg.TimerTornado >>>>> object at 0x7f894cb10f98>> >>>>> Traceback (most recent call last): >>>>> File "/usr/lib64/python3.4/site-packages/tornado/ioloop.py", line >>>>> 976, in _run >>>>> return self.callback() >>>>> File >>>>> "/usr/lib64/python3.4/site-packages/matplotlib/backend_bases.py", line >>>>> 1290, in _on_timer >>>>> ret = func(*args, **kwargs) >>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>> line 925, in _step >>>>> still_going = Animation._step(self, *args) >>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>> line 784, in _step >>>>> self._draw_next_frame(framedata, self._blit) >>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>> line 803, in _draw_next_frame >>>>> self._draw_frame(framedata) >>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>>> line 1106, in _draw_frame >>>>> self._drawn_artists = self._func(framedata, *self._args) >>>>> File "<ipython-input-2-f9290d8f6154>", line 22, in update >>>>> point.remove() >>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/artist.py", line >>>>> 139, in remove >>>>> self._remove_method(self) >>>>> File "/usr/lib64/python3.4/site-packages/matplotlib/axes/_base.py", >>>>> line 1479, in <lambda> >>>>> collection._remove_method = lambda h: self.collections.remove(h) >>>>> ValueError: list.remove(x): x not in list >>>>> ______ >>>>> Why does this happen? Is there a way to close the animation cleanly? >>>>> >>>>> 3. If I uncomment the `np.zeros` call, the pcolor array never updates >>>>> irrespective of the backend. I see the same behavior with `np.ones` as >>>>> well, even if the dtype is set to `float`. Is there are a way to start with >>>>> a all-zero pcolor that allow dynamic updates? >>>>> >>>>> 4. I'd like to be able to have the animation run until a certain >>>>> condition is met. Is there a way to code a clean break for the animation? >>>>> >>>>> >>>>> As always, any help is most appreciated! >>>>> >>>>> Ryan >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------ >>>>> ------------------ >>>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >>>>> Develop your own process in accordance with the BPMN 2 standard >>>>> Learn Process modeling best practices with Bonita BPM through live >>>>> exercises >>>>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >>>>> event?utm_ >>>>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_ >>>>> campaign=VA_SF_______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>> >>> > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT > Develop your own process in accordance with the BPMN 2 standard > Learn Process modeling best practices with Bonita BPM through live > exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- > event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
Tom, Thanks for the code. As it was given, I had to change `blit=True` in the `FuncAnimation` call in order to get this to work in a regular Qt backend. It did not work with the nbagg backend; however, if I used this code it works fine: #### %matplotlib nbagg import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animate class Testing(object): def __init__(self, ): self.fig = plt.figure() array = np.random.rand(4,5) array = np.zeros((4,5)) self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.)#, animated=True) self.pc.set_clim([0, 1]) self.points = [plt.scatter(np.random.rand(), np.random.rand())]#, animated=True)] def update(self, iter_num): array = np.random.rand(4*5) self.pc.set_array(array) for point in self.points: point.set_offsets([np.random.rand(), np.random.rand()]) #return (self.pc, ) + tuple(self.points) test = Testing() ani = animate.FuncAnimation(test.fig, test.update, interval=250, blit=False, frames=50) plt.show() #### Also this code solves the problem I was having with several scatter points being displayed upon multiple runs of the same code cell. I wasn't familiar with the "animated" keyword, and it is not well documented yet. Can you give me a quick explanation of what it is doing? Ben: thanks for the hint about the _stop() method. I might look into that for my example. Thank you all for your assistance. Things are working pretty much as I need now! Ryan On Sun, Apr 12, 2015 at 9:24 AM, Thomas Caswell <tca...@gm...> wrote: > You can > > > ``` > > #import matplotlib > > #matplotlib.use('nbagg') > > #%matplotlib nbagg > > import numpy as np > > import matplotlib.pyplot as plt > > import matplotlib.animation as animate > > > class Testing(object): > > def __init__(self, ): > > self.fig = plt.figure() > > array = np.random.rand(4,5) > > array = np.zeros((4,5)) > > self.pc = plt.pcolor(array, edgecolor='k', linewidth=1., > animated=True) > > self.pc.set_clim([0, 1]) > > self.points = [plt.scatter(np.random.rand(), np.random.rand(), > animated=True)] > > > def update(self, iter_num): > > array = np.random.rand(4*5) > > self.pc.set_array(array) > > for point in self.points: > > point.set_offsets([np.random.rand(), np.random.rand()]) > > > return (self.pc, ) + tuple(self.points) > > > > test = Testing() > > ani = animate.FuncAnimation(test.fig, test.update, interval=10, > blit=False, frames=50) > > plt.show() > > ``` > > note the addition of the `set_clim` line in the `__init__` method. > > > You can also update the scatter artist in-place. The other changes will > make it a bit for performant if you use bliting (which does not work with > nbagg currently) > > Sorry I missed that part of the question first time through. > > Tom > > On Sun, Apr 12, 2015, 08:31 Ryan Nelson <rne...@gm...> wrote: > >> Tom, >> >> Thanks for the links. It does seem like fragments of my problem are >> addressed in each of those comments, so I guess I'll have to wait for a bit >> until those things get resolved. For now, I can just tell my students to >> restart the IPython kernel each time they run the animation, which isn't >> that hard. It's too bad that there isn't a 'stop' method now, but it's good >> to hear that it isn't a completely terrible idea. >> >> I do still need help with Question #3 from my original email, though, >> because it affects both the Qt and nbagg backends, and it is a bit of a >> show stopper. I can't quite understand why initializing a pcolor(mesh) with >> random numbers makes it possible to update the array in an animation, but >> if you use all zeros or ones, it seems to be immutable. >> >> Ryan >> >> On Sat, Apr 11, 2015 at 8:35 PM, Thomas Caswell <tca...@gm...> >> wrote: >> >>> Ryan, >>> >>> I have not looked at your exact issue yet, but there seems to be some >>> underlying issues with animation and nbagg which we have not tracked down >>> yet. See: >>> >>> https://github.com/matplotlib/matplotlib/pull/4290 >>> https://github.com/matplotlib/matplotlib/issues/4287 >>> https://github.com/matplotlib/matplotlib/issues/4288 >>> >>> Running until a given condition is an interesting idea, but I think that >>> means the animation objects needs to have a public 'stop' method first! >>> >>> Tom >>> >>> On Fri, Apr 10, 2015 at 3:00 PM Ryan Nelson <rne...@gm...> >>> wrote: >>> >>>> Good afternoon, all! >>>> >>>> I'm really digging the nbagg backend, and I'm trying to use it to make >>>> an animation. As the subject suggests, though, I'm having some issues with >>>> these features. I'm using Python 3.4, Matplotlib 1.4.3, and IPython 3.1. >>>> Below is a small code sample that emulates my system. The pcolor call can >>>> be substituted for pcolormesh, and I see the same behavior. (Sorry this is >>>> a bit long. I tried to break it up as best as possible.) >>>> >>>> ############# >>>> #import matplotlib >>>> #matplotlib.use('nbagg') >>>> #%matplotlib nbagg >>>> import numpy as np >>>> import matplotlib.pyplot as plt >>>> import matplotlib.animation as animate >>>> >>>> class Testing(object): >>>> def __init__(self, ): >>>> self.fig = plt.figure() >>>> array = np.random.rand(4,5) >>>> #array = np.zeros((4,5)) >>>> self.pc = plt.pcolor(array, edgecolor='k', linewidth=1.) >>>> self.points = [plt.scatter(np.random.rand(), np.random.rand())] >>>> >>>> def update(self, iter_num): >>>> array = np.random.rand(4*5) >>>> self.pc.set_array(array) >>>> for point in self.points: >>>> point.remove() >>>> self.points = [plt.scatter(np.random.rand(), np.random.rand())] >>>> >>>> test = Testing() >>>> animate.FuncAnimation(test.fig, test.update, interval=1000, blit=False) >>>> plt.show() >>>> ############### >>>> >>>> 1. As is, this code runs fine with a Qt backend. It also runs fine as a >>>> first call in a notebook if the `show` call is commented out and the >>>> `%matplotlib` line is uncommented. However, if the `show` call is left in >>>> and the `matplotlib.use` call is uncommented, then the pcolor array >>>> changes, but the scatterpoint only shows on the first update and then >>>> disappears forever. What is the difference between these two invocations? >>>> >>>> 2. With the `%matplotlib` magic uncommented and `show` removed, the >>>> first invocation of this as a cell works fine. Closing the figure (with the >>>> red X) and running the cell again shows two scatter plot points. Running it >>>> a third time shows three scatter plot points. If you call `plt.clf` in the >>>> next cell, I get a series of errors as follows: >>>> _____ >>>> ERROR:tornado.application:Exception in callback <bound method >>>> TimerTornado._on_timer of <matplotlib.backends.backend_nbagg.TimerTornado >>>> object at 0x7f894cb10f98>> >>>> Traceback (most recent call last): >>>> File "/usr/lib64/python3.4/site-packages/tornado/ioloop.py", line >>>> 976, in _run >>>> return self.callback() >>>> File >>>> "/usr/lib64/python3.4/site-packages/matplotlib/backend_bases.py", line >>>> 1290, in _on_timer >>>> ret = func(*args, **kwargs) >>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>> line 925, in _step >>>> still_going = Animation._step(self, *args) >>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>> line 784, in _step >>>> self._draw_next_frame(framedata, self._blit) >>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>> line 803, in _draw_next_frame >>>> self._draw_frame(framedata) >>>> File "/usr/lib64/python3.4/site-packages/matplotlib/animation.py", >>>> line 1106, in _draw_frame >>>> self._drawn_artists = self._func(framedata, *self._args) >>>> File "<ipython-input-2-f9290d8f6154>", line 22, in update >>>> point.remove() >>>> File "/usr/lib64/python3.4/site-packages/matplotlib/artist.py", line >>>> 139, in remove >>>> self._remove_method(self) >>>> File "/usr/lib64/python3.4/site-packages/matplotlib/axes/_base.py", >>>> line 1479, in <lambda> >>>> collection._remove_method = lambda h: self.collections.remove(h) >>>> ValueError: list.remove(x): x not in list >>>> ______ >>>> Why does this happen? Is there a way to close the animation cleanly? >>>> >>>> 3. If I uncomment the `np.zeros` call, the pcolor array never updates >>>> irrespective of the backend. I see the same behavior with `np.ones` as >>>> well, even if the dtype is set to `float`. Is there are a way to start with >>>> a all-zero pcolor that allow dynamic updates? >>>> >>>> 4. I'd like to be able to have the animation run until a certain >>>> condition is met. Is there a way to code a clean break for the animation? >>>> >>>> >>>> As always, any help is most appreciated! >>>> >>>> Ryan >>>> >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------ >>>> ------------------ >>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >>>> Develop your own process in accordance with the BPMN 2 standard >>>> Learn Process modeling best practices with Bonita BPM through live >>>> exercises >>>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >>>> event?utm_ >>>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_ >>>> campaign=VA_SF_______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>> >>
On 16 April 2015 at 09:51, Benjamin Root <ben...@ou...> wrote: > A little birdie has told me that someone else is writing a new > comprehensive matplotlib book (I think it would replace Sandros' book). > Last I heard from the birdie, he was most of the way done with the > manuscript. Based on my experience with the edit/review process, I would > guess 2-3 more months to see it finished and published. > > Oh cool. I'll look out for this. Will it be advertised on this list?