如何分离颜色错误栏matlab [英] How to separate color errorbar matlab

查看:67
本文介绍了如何分离颜色错误栏matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下示例代码:

x = 0:pi/10:pi;
y = sin(x);
e = std(y)*ones(size(x));

figure
errorbar(x,y,e)

与水平线相比,如何给线涂上不同的颜色?

How are you able to color the line different compared to the horizontal lines?

我尝试了

errorbar(x,y,e,'--mo')

但这会一起改变所有这些人...

But this changes all of them together...

推荐答案

获取 errorbar 对象的句柄.它有两个子项,分别对应于数据图和误差线.然后,您可以分别设置每种颜色.

Get a handle to the errorbar object. It has two children, corresponding to the data plot and error bars respectively. Then you can set the color of each separately.

h = errorbar(x,y,e) %// a color spec here would affect both data and error bars
hc = get(h, 'Children')
set(hc(1),'color','b') %// data
set(hc(2),'color','g') %// error bars

这篇关于如何分离颜色错误栏matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆