nos nos - 1 year ago 142
Python Question

python matplotlib how to get multiple axes handles

My plot contains many subplots and I need a list of handles to treat each one of them. Right now I do the following

axes = [fig.add_subplot(2,3,1), fig.add_subplot(2,3,2),
fig.add_subplot(2,3,3), fig.add_subplot(2,3,4),
fig.add_subplot(2,3,5), fig.add_subplot(2,3,6)]

Is there a built-in function to get
more succinctly by simply specifying 2, and 3?

Answer Source

You can use:

f, ((ax1, ax2, ax3),(ax4, ax5, ax6)) = plt.subplots(2, 3)


f, axarray = plt.subplots(2, 3)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download