- 通过这样的动态作图,可以用来分析深度学习模型的性能。
示例代码1:
动态直方图
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
y1 = []
for i in range(50):
y1.append(i) # 每迭代一次,将i放入y1中画出来
ax.cla() # 清除键,清除所有的数值
#ax.bar(y1, label='test', height=y1, width=0.3)
ax.bar(y1, label='test', height=y1, width=0.3)
ax.legend()
plt.pause(0.1)
示例代码2:两条动态曲线叠加
# 测试程序
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 2 * np.pi, 0.1)
y1 = np.sin(x)
y2 = np.cos(x)
plt.figure(1)
plt.plot(x, y1)
plt.pause(2) #在figure(1)上绘制sin曲线,2s后自动关闭窗口
plt.figure(1)
plt.plot(x, y2)
plt.pause(2) #在figure(1)上绘制cos曲线,2s后自动关闭窗口
#plt.show()
plt.close()
示例代码3:
统计直方图比较
import numpy as np
import matplotlib.pyplot as plt
men_means = (20, 35, 30, 35, 27)
women_means = (25, 32,