我想使直方图上的颜色不透明,并且想在图上添加图例。我已经看到了很多资源,但是我在直方图中使用了groupby方法。我不确定如何为groupby的每个因素添加颜色
sia_table.groupby('subreddit')['sia_compound'].hist(bins = 20)
我建议使用subplots
创建一个轴,然后将绘图映射到它。
fig, ax = plt.subplots(1,1,figsize=(10,4))
sia_table.groupby('subreddit')['sia_compound'].hist(alpha=0.5, ax=ax)
ax.legend(sia_table['subreddit'].unique())
plt.show()