我有两个数据列表数据值(每100个数字)d1 = [0.5,0.6,0.45,........],d2 = [0.45,0.65,........] 。我想用两个列表数据绘制两个hist,如下图所示!如何用matplotlib绘制它,谢谢! 我的代码如下:
def plot_data(d1, d2):
fig, ax = plt.subplots()
ax.hist(d1, 100, 50, ec='red', fc='none', lw=1.5, histtype='step', label='n-gram')
ax.hist(d2, 100, 50, ec='green', fc='none', lw=1.5, histtype='step', label='ensemble')
ax.legend(loc='upper left')
plt.show()
但有错误:
mn, mx = [mi + 0.0 for mi in range]
TypeError: 'int' object is not utterable