python matplot 繪圖

import matplotlib.pyplot as plt
import numpy as np

x =[0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]
y1 = [0.1, 0.6844, 0.7598, 0.8658, 0.883, 0.9112, 0.9, 0.9202, 0.916, 0.9306, 0.9364, 0.9302, 0.941, 0.9358, 0.9422, 0.9388]
y2 = [2.303256938934326, 1.1635195175170898, 0.741816568183899, 0.46096420893669127, 0.41826898665428164, 0.3462135692596435, 0.3619256838798523, 0.3382941647529602, 0.303757034663856, 0.2671874636173248, 0.2314204734802246, 0.26542215099334715,0.2244397026747465, 0.22485867326259612, 0.20227264734506606, 0.2090572305202484]
# 這個是第一個figure對象,下面的內容都會在第一個figure中顯示
plt.figure("accuracy",figsize=(15,5))
ax1=plt.subplot(1,2,1)
plt.grid(color='r', linestyle='--', alpha=0.3)
plt.ylim((0,1))
plt.xlabel("Iter")
plt.ylabel("Accuracy")
plt.plot(x,y1)
# 這裏第二個figure對象
ax2=plt.subplot(1,2,2)
plt.grid(color='r', linestyle='--', alpha=0.3)
plt.xlabel("Iter")
plt.ylabel("Loss")
plt.plot(x, y2)
plt.show()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章