How do I get the FaceColor of a histogram if set to ‘auto’?
8 次查看(过去 30 天)
显示 更早的评论
h1 = histogram(data); get(h1, 'FaceColor');
Returns ‘auto’ and not the set color.
0 个评论
采纳的回答
Cindy Solomon
2015-6-2
Hi Gero,
The actual FaceColor is based on the 'ColorOrder' property of the axes, so if you assumed that the color order hasn't been changed and that the histogram was the first thing plotted on that axes, you could query the color from that. Histograms follow the same model as plot, wherein the first item plotted uses the first color on the ColorOrder, the second item uses the second color, etc. For example, if you knew that the histogram was the first item plotted, you could do something like:
colorList = get(gca,'ColorOrder');
histColor = colorList(1,:);
Could you please clarify why you would need to get the color this way? I work at MathWorks and would like to better understand your use-case so that I can pass your feedback to the developers.
Hope this helps!
2 个评论
Walter Roberson
2015-6-2
Cindy, is the implication that if you change order of Children in the axes, that the histogram might change color?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!