import matplotlib.pyplot as plt X1, Y1 = [], [] X2, Y2 = [], [] y_num=1 for line in open('wer.txt', 'r'): Y1.append(float(line[:-1])) X1.append(y_num) y_num=y_num+1 y_num=1 for line in open('srr.txt', 'r'): Y2.append(float(line[:-1])) X2.append(y_num) y_num=y_num+1 fig, ax = plt.subplots() plt.xticks(X1) plt.title("WER SRR") plt.xlabel("Number") plt.ylabel("Value") plt.plot(X1, Y1) plt.plot(X1, Y2) ax.legend(["WER", "SRR"]) plt.savefig('plot.png')