I have 2 folder each has 13 pics. I wanna plot any pair of them. for example the first pic from the first folder next to the first pic in the second folder. and then below it the second pair of photose from the first and second folder. could you please help me. I tried my self but id doesn’t work. here is what I did and what I got:
for i in range(len(data)): plt.subplot(122) imshow(data[i]) plt.title("Image") plt.show() plt.subplot(122) imshow(np.squeeze(preds_train_t[i] > 0.5)) plt.title("Predictions") plt.show() print('Next Picture') print('n')
Suppose the first folder is data and the second is preds_train_t.
My terible output from the above code:
Advertisement
Answer
The following code generates some sample images, then creates a figure with a 2×13 subplot geometry, and iterates over the lists to plot the images side by side
N=13 x,y = 20,50 train = [np.random.random(size=(x,y)) for _ in range(N)] preds_train_t = [np.random.random(size=(x,y)) for _ in range(N)] fig, axs = plt.subplots(len(train),2) for i in range(N): axs[i,0].imshow(train[i]) axs[i,1].imshow(preds_train_t[i])