Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

In the beginning it says there is a class matplotlib.figure.AxesStack, and then

The AxesStack is a 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 error

AttributeError: 'Figure' object has no attribute 'ax_stack' 
like image 572
Håkon Hægland Avatar asked Jun 08 '14 09:06

Håkon Hægland


People also ask

What does PLT axis () do?

axis() method allows you to set the x and y limits with a single call, by passing a list which specifies [xmin, xmax, ymin, ymax] : In [11]: plt. plot(x, np.

How do you add axes to a figure?

add_axes([left, bottom, width, height]) to add an axes onto a fig . This function enables arbitrary layouts of axes on fig by taking the dimensions ( [left, bottom, width, height] ) of the new axes (you can find an example here). All four numbers should be in fractions of figure width and height.

What is fig Add_axes Python?

add_axes plot inside plot matplotlib To create a figure object, use the figure() method. To define data points x and y. To plot a graph, use the plot() method of pyplot module. To add a plot inside an already generated plot, use the add_axes() method.


1 Answers

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

ax_list = fig.axes 

(doc)

like image 82
tacaswell Avatar answered Sep 19 '22 08:09

tacaswell