matplotlib - matplotlib:如何从直方图条中获取颜色(或 facecolor)?
问题描述
我有一个使用列表作为数据源的直方图,我想获取每个条形的颜色或 facecolor 以诊断问题。
patches.facecolor()
不适合我。
#The histogram
n, bins, patches = ax.hist([lst_outliers, lst_standard], num_bins, rwidth=0.8, color=['red','blue'])
#This is how I'm trying to access the facecolor attribute of ax.patches:
patches[0][21].get_facecolor()
#It yields the following for all bars; I can't tell if this is some kind of color code:
(1.0, 0.0, 0.0, 1.0)
#Ultimately, I would like to build on the following to diagnose another problem (some day soon I will write list comps):
for i, each_bin in enumerate(bins):
print(str(i+1) + " " + str(each_bin))
解决方案
推荐阅读
- amazon-web-services - Nginx:客户端请求正文缓冲到临时文件
- javascript - 使用 redux 为什么我的应用程序状态 isAuthenticated 在任何类型的重新加载后都不会保持设置为 true?
- prolog - 执行列表转换,Prolog
- python - 如何访问电子表格中的另一个页面?
- javascript - 车把问题
- android - 方法代码太大!android compileSdkVersion 27 更改为 compileSdkVersion 30 后
- angular - 在 NgRx 中,在哪里将来自服务器的响应数据(通过副作用获得)转换为组件可以理解的状态?
- python - 如何使用 python 将 UTC 时间转换为 UTC 中的相应日期和时间?
- python - 如何永远运行python代码直到停止它?
- javascript - 使用 Javascript 的文本框中的 Control+N 键事件