繪製多圖
關鍵:
fig = plt.figure(1)
表示新建第幾個圖
import matplotlib.pyplot as plt
fig = plt.figure(1)
plt_rec_loss = [1,2,3,4,5,6]
plt_rec_recall = [4,3,6,5,8,9]
plt.xlabel("epoch")
plt.ylabel("loss")
plt.plot(range(len(plt_rec_loss)), plt_rec_loss)
fig = plt.figure(2)
plt.xlabel("epoch")
plt.ylabel("recall")
plt.plot(range(len(plt_rec_recall)), plt_rec_recall)
plt.show()
繪製多例圖
import matplotlib.pyplot as plt
plt_rec_loss = [1,2,3,4,5,6]
plt_rec_recall = [4,3,6,5,8,9]
plt.xlabel("epoch")
plt.ylabel("test")
plt.plot(range(len(plt_rec_loss)), plt_rec_loss)
plt.plot(range(len(plt_rec_recall)), plt_rec_recall, color="r")
plt.show()
繪製多個子圖
關鍵:
plt.subplot(211)
將畫布分爲2行1列,這個子圖位於被劃分的畫布的第一塊子圖位置。
plt.subplot(212)
將畫布分爲2行1列,這個子圖位於被劃分的畫布的第二塊子圖位置。
import matplotlib.pyplot as plt
plt_rec_loss = [1,2,3,4,5]
plt_rec_recall = [4,3,6,7,8,9]
ax1 = plt.subplot(211)
plt.xlabel("epoch")
plt.ylabel("loss")
plt.plot(range(len(plt_rec_loss)), plt_rec_loss)
ax2 = plt.subplot(212)
plt.xlabel("epoch")
plt.ylabel("recall")
plt.plot(range(len(plt_rec_recall)), plt_rec_recall, color="r")
plt.show()