I am trying to plot three graphs in a row, but running into a weird behavior.
I am trying to print the filename out before each subplot of the loop.
for file in filenames:
data = np.loadtxt(file, delimiter = ",")
x = np.mean(data,axis=0)
y = np.min(data,axis=0)
z = np.max(data,axis=0)
f,(plot1,plot2,plot3) = plt.subplots(1,3,figsize=(20,5))
print(file)
plot1.plot(x)
plot2.plot(y)
plot3.plot(z)
The only problem for my program is that all the graphs are plotted after the print(file)
statement. So it became something like following:
filename1
filename2
filename3
Graph1 Graph2 Graph3
Graph1 Graph2 Graph3
Graph1 Graph2 Graph3
What I wanted is :
filename1
Graph1 Graph2 Graph3
filename2
Graph1 Graph2 Graph3
filename3
Graph1 Graph2 Graph3
I also tried to look up title for subplot, apparently, there isn't such attributes
Why does subplot only plotted after all the print statements? How do I print the graphs right after each filename is print? Is there a way that i can supply a title name for each subplot?