0

I want to get two plots next to each other, but the problem is I am not able to figure out how to use a subplot in my case. The code to plot one image is pasted below.

plt.figure(figsize=(30, 30))
plt.title('Clean Image')
plt.imshow(clean_crop, cmap="gray")
plt.plot(clean_lr, clean_ub, 'gx', markersize=40, markeredgewidth=5)
plt.savefig("aligned_cropped_img/FCN_false_neg/" + "Img # " + str(i) + " G_cord" + str(false_neg[i]) + ".jpeg",
            dpi=100,
            bbox_inches='tight', pad_inches=0)
plt.clf()

clean_crop is a numpy 2d array, and clean_ur and clean_ub are coordinates that I want to highlight. The second plot also has the same format with coordinates; this whole thing is in a loop.

Thank you.

Daniel Walker
  • 6,380
  • 5
  • 22
  • 45

1 Answers1

0

Checkout the examples at Matplotlib, in some of them you will find how to do that. Basically what you need to do is use plt.subplots(1, 2), in this example you can see how something similar is used to create a grid of three plots (a 1x3 grid)

So instead of plt.figure(figsize=(30, 30)) you would have the following:

fig, axs = plt.subplots(1, 2, figsize=(30, 30))

With that you would use axs[0] for the first plot and axs[1] for the second. I would suggest you make the figure size bigger to acommodate both plots.

Arturo Mendes
  • 490
  • 1
  • 6
  • 11