Skip to main content

Matplotlib Subplots

# fig = plt.figure()

fig = plt.figure(figsize=(50,50))

ax = fig.add_subplot(1, 2, 1)

plt.imshow(imgArray1, cmap='gray', vmin = 0, vmax = 255, interpolation='none', aspect='auto') #remove cmap to see colors

ax.set_title('title1')

ax = fig.add_subplot(1, 2, 2)

plt.imshow(imgArray2, cmap='gray', vmin = 0, vmax = 255, interpolation='none')

plt.show() 


# # Uncomment to save image and see scores on title of image

# picoutpath = os.path.join(self.outdir, 'lax_classify_jpg_out', labeldir)

# os.makedirs(picoutpath, exist_ok=True)

# picoutpath = os.path.join(picoutpath, filename.replace('.npy', '.jpg'))


# plt.imshow(imgarr, cmap='gray', interpolation=None)

# plt.title(f' [ GT:{gtrth_x} PD:{predc_x} PRB:{ma_score:.2f} ]')

# plt.savefig(picoutpath, dpi=200)

# plt.close()


fig, axs = plt.subplots(1, 2, dpi=200)

    i = 0 

    im = axs[i].imshow(img, cmap='gray', interpolation=None)

    axs[i].set_title(f'Input Image [GT:{lbl} PD:{prd}]')

    axs[i].get_xaxis().set_visible(False)

    axs[i].get_yaxis().set_visible(False)


    i = 1

    im = axs[i].imshow(cam, cmap='hot', interpolation=None)

    axs[i].set_title(f'Heat Map [Th: {th}]')

    axs[i].get_xaxis().set_visible(False)

    axs[i].get_yaxis().set_visible(False)


    plt.savefig(oppath)

    plt.close()