[Matplotlib-devel] Confusion about draw_artist

Matthew Brett matthew.brett at gmail.com
Fri Mar 24 10:26:48 EDT 2017


On Fri, Mar 3, 2017 at 11:19 PM, Matthew Brett <matthew.brett at gmail.com> wrote:
> Hi,
>
> On Thu, Jan 19, 2017 at 11:54 AM, Matthew Brett <matthew.brett at gmail.com> wrote:
>> Hi,
>>
>> Sorry to keep displaying my confusion on this one but...
>>
>> On Wed, Jan 4, 2017 at 6:58 PM, Thomas Caswell <tcaswell at gmail.com> wrote:
>>> Unless you have flagged the artist as `animated` (via `set_animated` or by
>>> kwarg), it will be drawn as part of the next re-draw.
>>
>> Adding `set_animated` doesn't help in the example above;
>>
>> fig, ax = plt.subplots(1, 1)
>> ax.set_animated(True)
>> im = plt.imshow([[1, 2], [3, 4]])
>> fig.canvas.draw()
>> ax.draw_artist(im)
>>
>>> You are better off
>>> just changing the `fig.canvas.draw()` to `fig.canvas.draw_idle()` and
>>> letting the GUI decide when to re-draw things.
>>
>> Changing to `fig.canvas.draw_idle()` above doesn't prevent the error
>> from `draw_artist`, but I guess I should not have expected it would.
>> So I guess my question is - how do I use `draw_artist` in this case?
>> Is there any way to make sure that the renderer is cached first?
>>
>>> If you want to get any performance gain from animated artists + draw_artist
>>> you will need to use blitting (which will work with the OSX backend in 2.0).
>>
>> Yup, the real code does use blitting, but thanks for the reminder,
>
> Again - sorry to persist - but I'd be really grateful for any advice,

Sorry - again again - but can I nose this one up towards the surface?

Cheers,

Matthew


More information about the Matplotlib-devel mailing list