Update individual elements (i.e an artist) for drawing

Hi,

I was just wondering, how would I go about redrawing only a single element (i.e. an artist)? I know that matplotlib.artist.Artist has a draw() method that accepts a renderer as the argument.

I tried something along the lines of:

renderer = fig.canvas.get_renderer()
title = ax.set_title(“This is my title”)
title.draw(renderer)

But have not had any luck. I’m not sure what I’m missing. Any help would be greatly appreciated.

Thanks,
Aman

Aman Thakral, on 2011-02-09 15:40, wrote:

Hi,

I was just wondering, how would I go about redrawing only a single element
(i.e. an artist)? I know that matplotlib.artist.Artist has a draw() method
that accepts a renderer as the argument.

I tried something along the lines of:

renderer = fig.canvas.get_renderer()
title = ax.set_title("This is my title")
title.draw(renderer)

But have not had any luck. I'm not sure what I'm missing. Any help would
be greatly appreciated.

Hi Aman,

To see the affects of rendering something new, you can use:

  ax.figure.canvas.blit(ax.title.get_bbox_patch())

If you intend to change the title several times, however, the
above will just keep over-plotting on top of the previous titles.
In that case, you'll want to use the animated=True keyword and
canvas.restore_region along with the blitting -- see the
animation examples for how to do that.

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7