|
From: Michiel de H. <mjl...@ya...> - 2014-03-14 10:34:40
|
Hi Ryan, In matplotlib, drawing is done as part of the call to figure.draw(renderer). The MacOSX backend makes this call from the event loop callback (i.e., the drawRect function in src/_macosx.m). Outside of the event loop callback, the graphics context (CGContextRef on Macs) is undefined, and no drawing can take place. In the animations module, event_source is a timer that periodically calls _step, which calls _draw_next_frame, which calls _post_draw to do the blitting. But since the timer lives outside if the event loop, blitting will fail on Macs; there simply is no graphics context to draw to. The solution is to split the blitting into two parts: - A front-end blitting function that tells matplotlib to blit (this is the function called by the timer) - A back-end blitting function that does the actual blitting (as part of the call to figure.draw(renderer); the back-end blitting function is implemented in the backend). In a sense, this is the same as for the other graphics functions (e.g. there is a front-end "plot" function, and a back-end "draw_path" function). See the discussion here for more information: https://github.com/matplotlib/matplotlib/issues/531 (this discussion also went into other issues though). Best, -Michiel. -------------------------------------------- On Thu, 3/13/14, Ryan May <rm...@gm...> wrote: Subject: Re: [Matplotlib-users] Animate on Mac O$ To: "Michiel de Hoon" <mjl...@ya...> Cc: "Christophe Bal" <pro...@gm...>, "Matplotlib" <mat...@li...> Date: Thursday, March 13, 2014, 8:29 PM > On Mar 13, 2014, at 17:55, Michiel de Hoon <mjl...@ya...> wrote: > > The problems with animations on Mac > are not so much related to the backend, > but to the animations code itself. Animations > with the MacOSX backend cannot be fixed > without redesigning the animations module. Can you give me a better idea why you think so? I wrote the original and have a Mac now... Ryan |