简体   繁体   English

Python Matplotlib直方图颜色

[英]Python Matplotlib Histogram Color

I hope you are well. 我希望你一切都好。

I am plotting a histogram using Matplotlib. 我正在使用Matplotlib绘制直方图。 I would like the color of the histogram to be "sky blue". 我希望直方图的颜色是“天蓝色”。 But the data overlaps, and produces a histogram which is nearly black in color. 但数据重叠,并产生一个近乎黑色的直方图。

Thanks for helping 谢谢你的帮助

plt.hist(data, color = "skyblue")

Below is how the histogram looks. 下面是直方图的外观。 As you can see, though I've specified the color as "Skyblue, the histogram on the right is nearly black 正如您所看到的,虽然我已将颜色指定为“Skyblue”,但右侧的直方图几乎是黑色 在此输入图像描述

The reason for the histogram to look black is that the bars' surrounding lines (which are black) take most of the space. 直方图看起来是黑色的原因是条纹的周围线条(黑色)占据了大部分空间。

Options would be to get rid of the edges by setting the linewidth to zero: 选项是通过将线宽设置为零来消除边缘:

plt.hist(data, color = "skyblue", lw=0)

and/or to set the edgecolor to the same color as the bars itself 和/或将edgecolor设置为与条本身相同的颜色

plt.hist(data, color = "skyblue", ec="skyblue")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM