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')


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM