小编Luc*_*uca的帖子

让每个直方图箱具有不同的颜色

我绘制了一个直方图,并希望每个垃圾箱都有不同的颜色。现在我收到错误消息: “‘color’关键字参数每个数据集必须有一种颜色,但提供了 1 个数据集和 10 种颜色”

我还附上了直方图的屏幕截图。提前致谢 直方图

decades = np.arange(1910, 2020, 10)
colors = ['aqua', 'red', 'gold', 'royalblue', 'darkorange', 'green', 'purple', 'cyan', 'yellow', 'lime']

plt.figure(figsize=(12,7))
plt.hist(df.Year, bins=decades, color=colors)
plt.xticks(decades);
Run Code Online (Sandbox Code Playgroud)

python matplotlib histogram pandas seaborn

1
推荐指数
1
解决办法
7436
查看次数

标签 统计

histogram ×1

matplotlib ×1

pandas ×1

python ×1

seaborn ×1