如何更改直方图中特定箱的颜色?
我在 MATLAB 中编写了一个绘制直方图的代码。我需要将其中一个垃圾箱涂成与其他垃圾箱不同的颜色(假设是红色)。有人知道该怎么做吗?例如,给定:
A = randn(1,100);
hist(A);
我如何使 0.7 属于红色的 bin ?
I wrote a code in MATLAB that plots a histogram. I need to color one of the bins in a different color than the other bins (let's say red). Does anybody know how to do it? For example, given:
A = randn(1,100);
hist(A);
How would I make the bin that 0.7 belongs to red?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像 Jonas 建议 那样制作两个重叠条形图的另一种方法是调用
bar
将垃圾箱绘制为一组 修补对象,然后修改'FaceVertexCData'
属性 重新着色补丁面:这是输出:
An alternative to making two overlapping bar plots like Jonas suggests is to make one call to
bar
to plot the bins as a set of patch objects, then modify the'FaceVertexCData'
property to recolor the patch faces:And here's the output:
我想最简单的方法是先绘制直方图,然后在其上绘制红色框。
I guess the easiest way is to draw the histogram first and then just draw the red bin over it.