I am trying to plot two satellite images next to eachother. The images is of the same area and have the same shape. One image is true color, and the other i have performed my analysis on. I want the images to appear the same size in the plot, as it is easier to compare. However, i only want the colorbar for the one where i have performed my analysis to be included. The image shape is 300*300 if that matters. And i want a nice plot where both images have the same height Y, width X.
This is how i usually plot:
plt.figure(figsize = (20,15))
plt.subplot(121)
plt.imshow(rgb_img)
plt.axis("Off")
plt.subplot(122)
plt.imshow(analysis)
plt.colorbar()
plt.axis("Off")
plt.subplots_adjust(wspace=0.1) # Adjust the horizontal space between subplots
plt.show()
And i would prefer to just add something so that this happens automatically.
The closest i got was:
fig = plt.figure(figsize=(40, 30))
gs = GridSpec(1,7)
# Define the first subplot to take up one part
ax1 = fig.add_subplot(gs[0,:3])
ax1.imshow(rgb_img)
ax1.axis("off")
# Define the second subplot to take up two parts
ax2 = fig.add_subplot(gs[0, 3:6])
ax2.imshow(analysis)
ax2.axis("off")
#ax2.colorbar()
cax = fig.add_subplot(gs[0,6: ])
fig.colorbar(im, cax=cax)
plt.show()
However, i am still not happy about the ratio of colorbar to the images, and it is frustrating to change the ratios manually.
Any help would be greatly appreciated.