import pandas
import matplotlib.pyplot as plt
# 设置csv文件路径
file1 = r''
file2 = r""
file3 = r""
# 防止中文乱码
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
import pandas as pd
import matplotlib.pyplot as plt
# 读取CSV文件
df1 = pd.read_csv(file1)
df2 = pd.read_csv(file2)
df3 = pd.read_csv(file3)
# 确保'Step'列是索引
df1.set_index('Step', inplace=True)
df2.set_index('Step', inplace=True)
df3.set_index('Step', inplace=True)
# 绘制'Value'列的折线图,并设置线条格式
plt.plot(df3['Value'], color='blue', linewidth=2, linestyle='-', label='IRDPNet')
plt.plot(df2['Value'], color='red', linewidth=2, linestyle='--', label='Baseline')
#折线名字的位置以及选择形式
plt.legend(loc=4, fancybox=True)
# 设置坐标轴的格式
plt.tick_params(axis='both', labelsize=14)
plt.xlabel('epoch') # 设置横坐标名称
plt.ylabel('mIou/%') # 设置纵坐标名称
plt.grid() # 显示网格线
# 设置纵坐标的范围
plt.xlim(0, 100)
plt.ylim(0, 100) # 设置纵坐标范围为0到100
# 保存图表为png文件
plt.savefig('保存路径')
# 将绘制的图表显示在屏幕上
plt.show()
论文中利用python运行csv中的数据进行画图
最新推荐文章于 2024-05-30 10:12:06 发布