Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a method to get the get parent canvas for axes in matplotlib?

I'm working with matplotlib to build a very basic GUI around a statistical model/simulation. I'd like to add a timer of this sort, to allow for some animation. Problem: the way my objects are set up, I have easy access to MPL axes objects, but not canvasses.

Is there a method to get the get parent canvas for axes in matplotlib? Seems like the simplest way to solve this problem.

Alternatively, is there an obvious workaround? I'm pretty new to matplotlib.

like image 434
Abe Avatar asked Mar 15 '12 18:03

Abe


1 Answers

It's just ax.figure.canvas.

e.g.

import matplotlib.pyplot as plt
ax = plt.gca()

canvas = ax.figure.canvas 
like image 60
Joe Kington Avatar answered Sep 19 '22 15:09

Joe Kington