How to get a list of axes for a shape in pyplot?

I am new to python and pyplot . I am trying to understand the documentation for the Matplotlib API related to the drawing of the Drawing API .

The beginning says there is a class matplotlib.figure.AxesStack , and then

AxesStack is callable where ax_stack () returns the current axes

When I try to use this in a program

 import numpy as np import matplotlib.pyplot as plt n=4 v=np.arange(n) X,Y = np.meshgrid(v,v) Z=np.random.rand(n-1,n-1) fig, ax = plt.subplots() plt.pcolormesh(X, Y, Z) plt.axis('tight') plt.colorbar() ast=fig.ax_stack() plt.show() 

I get an error

 AttributeError: 'Figure' object has no attribute 'ax_stack' 
+6
source share
1 answer

The axes property returns a list of axes objects in the Figure object:

 ax_list = fig.axes 

( doc )

+16
source

Source: https://habr.com/ru/post/970529/


All Articles