I am writing a code that would display images one by one after the user sends input signal like enter.Following is my code
import numpy as np
import matplotlib.pyplot as plt
from logistic_regression_class.utils_naseer import getData
import time
X,Y=getData(balances=False) // after getting X data and Y labels
# X and Y are retrieved using famous kaggle facial expression dataset
label_map=['Anger','Disgust','Fear','Happy','Sad','Surprise','Neutral']
plt.ion()
for i in range(len(Y)):
x=X[i]
plt.figure()
plt.imshow(x.reshape(48,48),cmap='gray')
plt.title(label_map[Y[i]])
plt.show()
_ = input("Press [enter] to continue.")
plt.close()
Output:
I am only getting blank images with no data and each time I presses enter I get a new blank image.But When I removed plt.close() then all the plots showed up in separate window but that will be too many windows popping up. I also used suggestion from stackoverflow this link.
What is the correct way to show images in a loop one after another using a use command input?
Screen Shots:
a) With plt.close()
b) Without plt.close()