我正在使用 matplotlib.pyplot 来可视化我的数据。在 pandas 中,我有“hour”和“favourite_count”两列。hour 的值从 0 到 24。"favourite_count" 是一个连续变量。我想要绘制一个条形图,以可视化每个小时的平均 "favourite_count"。目前我正在绘制一个基本图表,如下所示。在 y 轴上,这会为每个小时绘制“favourite_count”的总和/最大值(我不确定哪个)。我该如何绘制一个可视化 hour vs average_favorite_count_for_hour 的图表?
plt.bar(result['hour'], result['favourite_count'])
plt.xlabel('hour')
plt.ylabel('favourite_count')
plt.title('hour vs popularity', y=1.1)
plt.grid()
plt.show()