how to use matplotlib to plot multi-figures

Ke Gui
1 min readJun 6, 2020

--

you can do all in one go, or define your figure and add subplot step by step

f, axarr = plt.subplots(2,2)
axarr[0,0].imshow(image_datas[0])
axarr[0,1].imshow(image_datas[1])
axarr[1,0].imshow(image_datas[2])
axarr[1,1].imshow(image_datas[3])
fig = plt.figure()
ax1 = fig.add_subplot(2,2,1)
ax1.imshow(...)
ax2 = fig.add_subplot(2,2,2)
ax2.imshow(...)
ax3 = fig.add_subplot(2,2,3)
ax3.imshow(...)
ax4 = fig.add_subplot(2,2,4)
ax4.imshow(...)

both ways work

f, axarr = plt.subplots(1,2)
axarr[0].imshow(scaled)
axarr[1].imshow(img_0)

or

f, axarr = plt.subplots(1,2)
axarr[0].imshow(scaled)
axarr[1].imshow(img_0)

but not for 2 subplots like this:

f, axarr = plt.subplots(1,2)
axarr[0,0].imshow(scaled)
axarr[0,1].imshow(img_0)

--

--

Ke Gui
Ke Gui

Written by Ke Gui

An ordinary guy who wants to be the reason someone believes in the goodness of people. He is living at Brisbane, Australia, with a lovely backyard.

No responses yet