import matplotlib.pyplot as plt
import numpy
from matplotlib.pyplot import MultipleLocator
import os
import numpy as np
import pandas as pd
import sys
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
################################ 1、修改路径 'r', encoding='utf-8'
df_1 = pd.read_csv('G:/Px-OUTPUT/train-seg/xx/results.csv')
# ###################### 2、修改对应自己的训练总epoch数(对应下面x坐标)
epoch_nums = 100
# 将.csv读取的表格数据以列于行形式转成列表,此时的维度为(0, )
list_AP_mask = df_1.iloc[:-1, -8].to_list()
print(list_AP_mask)
# 将列表转为numpy数组形式,并更改与x等同的维度为(100, )
T = np.array(list_AP_mask)
T = T.reshape(100,)
print(T.shape)
#sys.exit()
# list_P_box = []
# list_R_box = []
# list_mAP50_box = []
# list_AP_box = []
#
# list_P_mask = []
# list_R_mask = []
list_AP_mask = []
# list_mAP50_mask = []
plt.rc('font', family='Times New Roman', size=15) # 全局中英文为字体“罗马字体”
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
x = np.arange(0, 100, 1)
print(x.shape)
plt.xlim(0, 100)
plt.ylim(0, 0.35)
plt.plot(x, T, linewidth=3, label="AP(IOU=0.5:0.95)")
plt.xlim(0, 100)
# 把x轴的刻度间隔设置为10,并存在变量里 ############################### 设置坐标轴间隔
x_major_locator = MultipleLocator(10)
ax = plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
# y_major_locator = MultipleLocator(10)
# ay = plt.gca()
# ay.xaxis.set_major_locator(y_major_locator)
plt.xlabel('Epoch')
plt.ylabel('Precision')
plt.grid(True)
plt.legend(loc="lower right")
# plt.legend(loc="upper left")
plt.show()
E:\myprogram\anaconda\envs\python3.6\python.exe E:/xxx/xx/read_csv.py
[0.027732999999999997, 0.043930000000000004, 0.076258, 0.09657400000000001, 0.10355, 0.12327, 0.12332, 0.14339000000000002, 0.1381, 0.15563, 0.15955999999999998, 0.18033, 0.17088, 0.18822, 0.17684, 0.19351, 0.19538, 0.18424000000000001, 0.19119, 0.20776, 0.20529, 0.20817, 0.21753000000000003, 0.21278000000000002, 0.22803, 0.22714, 0.22995, 0.2274, 0.23564000000000002, 0.2447, 0.24164000000000002, 0.24648, 0.24959, 0.25674, 0.25066, 0.25248000000000004, 0.24323000000000003, 0.24770999999999999, 0.25461999999999996, 0.25793, 0.24966999999999998, 0.25883, 0.25345, 0.26056, 0.26711999999999997, 0.26764, 0.26607, 0.26988, 0.27003, 0.27007, 0.27265, 0.26886, 0.2754, 0.27551, 0.28046, 0.2869, 0.27865, 0.27926999999999996, 0.28401, 0.27218000000000003, 0.28037, 0.28009, 0.28194, 0.28404, 0.28476, 0.28724, 0.28474, 0.28733000000000003, 0.28386999999999996, 0.29066, 0.28081, 0.29454, 0.29118, 0.28915, 0.29177, 0.29219, 0.292, 0.28731, 0.28829, 0.29073000000000004, 0.2899, 0.29514, 0.29793000000000003, 0.29234, 0.30144, 0.29134, 0.29718, 0.2987, 0.30075, 0.29709, 0.29002, 0.29341999999999996, 0.29591999999999996, 0.30126, 0.30104000000000003, 0.304, 0.2965, 0.2991, 0.2962, 0.29769]
(100,)
(100,)
Process finished with exit code 0