0

I am trying to subplot 4 figures i have already saved before as png.

This is the code i am using:

img1 = mpimg.imread(r'C:\Users\nikos.000\png\kicks_UCS_elec.png')
img2 = mpimg.imread(r'C:\Users\nikos.000\png\DW_UCS_elec.png')

img3 = mpimg.imread(r'C:\Users\nikos.000\png\energ_UCS_elec.png')
img4 = mpimg.imread(r'C:\Users\nikos.000\png\UCS_elec_kinet.png')



f, ax = plt.subplots(2,2)
ax[0,0].imshow(img1)

ax[0,1].imshow(img2)

ax[1,0].imshow(img3)

ax[1,1].imshow(img4)
f.axes.get_xaxis().set_visible(False)
f.axes.get_yaxis().set_visible(False)

And this is the result I am getting:

enter image description here

I want to get rid of the extra axes printed in each subplot. Is this possible?

  • Maybe this could help: plt.axis('off'), please see the link below. https://stackoverflow.com/questions/9295026/matplotlib-plots-removing-axis-legends-and-white-spaces – Bo Wang Jan 16 '21 at 04:47
  • I have already tried this one but it does not make any difference –  Jan 16 '21 at 04:48

1 Answers1

1

You should turn off each axis. Using your own code for example:

img1 = mpimg.imread(r'C:\Users\nikos.000\vlahos\png\kicks_UCS_elec.png')
img2 = mpimg.imread(r'C:\Users\nikos.000\vlahos\png\DW_UCS_elec.png')

img3 = mpimg.imread(r'C:\Users\nikos.000\vlahos\png\energ_UCS_elec.png')
img4 = mpimg.imread(r'C:\Users\nikos.000\vlahos\png\UCS_elec_kinet.png')



f, ax = plt.subplots(2,2)
ax[0,0].imshow(img1)

ax[0,1].imshow(img2)

ax[1,0].imshow(img3)

ax[1,1].imshow(img4)

for a in ax.flat:
    a.axis('off')
gepcel
  • 1,326
  • 11
  • 21