【发布时间】:2021-05-09 11:14:57
【问题描述】:
我必须使用 matplotlib 绘制直方图。问题是我不明白为什么我的直方图不会显示,轴被绘制并标记但没有显示图表(见下图),下面是我的代码。请告诉我如何解决这个问题。
val=list(movie['Year'].value_counts().values)
#movie is a dataframe and in this case val has following values
#[297, 127, 98, 91, 64, 63, 60, 53, 52, 51, 44]
plt.hist(val) #val is a list
plt.ylim([2006,2016])
plt.yticks(np.arange(2006, 2017, 1))
plt.show()
【问题讨论】:
-
它是一个数字列表
-
val=list(movie['Year'].value_counts().values)
-
这就是我填充 val 的方式,movie 是一个数据帧
标签: python matplotlib