代码示例:
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt method_path = "./results_org1.txt" org = pd.read_csv(method_path, header=None) method_path = "./results_exp1.txt" exp = pd.read_csv(method_path, header=None) epochs = list(range(1,len(org)+1)) plt.plot(epochs, org.loc[:,9], label="org_data") plt.plot(epochs, exp.loc[:,9], label="exp_data") plt.xlabel('epochs',fontsize=16) plt.ylabel('percision',fontsize=16) plt.legend(loc=4,fontsize=16) plt.title('Percision vs.epochs ',fontsize=16) plt.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.75',dashes=(15, 10)) plt.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.75',dashes=(15, 10)) plt.show()
画图结果: