Reputation: 163
I'd like to plot two images side by side in Python using matplotlib. However I don't want to create separate subplots. I want to plot two images in the same figure so that I can draw correspondences between the two images. See image below.
In Matlab I believe this can be done using imshow([I1, I2]) however the python API for matplotlib does not accept an array of images. Is there a way to do this in python?
Upvotes: 3
Views: 12043
Reputation: 1327
If you use numpy you can simply make one large array that represents the two images using the numpy concatenate function:
import numpy as np
import matplotlib.pyplot as plt
img_A = np.ones((10,10))
img_B = np.ones((10,10))
plot_image = np.concatenate((img_A, img_B), axis=1)
plt.imshow(plot_image)
plt.show()
Upvotes: 9