Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the AxesImages from matplotlib

Tags:

matplotlib

all, I use the such code to plot the images

import matplotlib.pyplot as plt

plt.imshow(array,cmap='jet')
plt.show()

however, now I want to get the handle (im) of im=plt.imshow(array,cmap='jet') How can I get the handle of im if I ignore the handle in the second step.

like image 310
user3306127 Avatar asked Aug 26 '14 12:08

user3306127


1 Answers

You can call the method get_images() on the ax.

Example code:

ax = plt.gca() 
ax.imshow(array) 
ax.get_images() # returns a list of AxesImage objects if any.
like image 52
Princy Avatar answered Oct 05 '22 22:10

Princy