PYTHON 绘制eps曲线图
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv(r'D:\实验数据记录\kcss\2次\monitor.csv')
# nodeIp = "192.168.1.27"
# nodeIp = "192.168.1.90"
# nodeIp = "192.168.1.100"
# nodeIp = "192.168.1.127"
nodeIp = "192.168.1.187"
df = data.loc[data['node_ip'] == nodeIp, :]
print(df)
# 分别拿到时间戳与值
values = df['cpu_util'].values
timestamps = df['record_time'].values
# 为了避免数据太多可以考虑展现其中一部分
pieceSize = 4
showPiece = 1 # [1,pieceSize]
# 开始准备绘制
plt.figure(num='cpu4', figsize=(16, 7))
# plt.title('cpu4-'+str(showPiece))
# start = int(len(timestamps)*(showPiece/pieceSize))
# end = int(len(timestamps)*((showPiece+1)/pieceSize))
start = 0
end = len(timestamps)
plt.plot(timestamps[start:end], values[start:end], color="BLACK")
plt.show()
# 如果不展示而是导出为 eps 文件,非常简单
#plt.savefig(nodeIp + str(showPiece) + '.eps', format='eps', bbox_inches='tight')
plt.savefig(nodeIp + '.eps', format='eps', bbox_inches='tight')
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步