Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get subplots of matplotlib Figure?

Tags:

matplotlib

I know that I can use plt.subplots() to get handles for Figure and subplots at the same time, but how to get all subplots (or specific subplot) of an existing Figure instance?

like image 400
Aivar Avatar asked Jul 11 '17 17:07

Aivar


1 Answers

If figure is a Figure instance you can get the axes inside it via

allaxes = fig.get_axes()

The return of this (allaxes) is a list of all the axes inside the figure. Which subplot is which in this list, you need to know from the figure or some other source.

like image 62
ImportanceOfBeingErnest Avatar answered Sep 16 '22 11:09

ImportanceOfBeingErnest