给定以下示例代码:
x = 0:pi/10:pi;
y = sin(x);
e = std(y)*ones(size(x));
figure
errorbar(x,y,e)
你是如何将这条线与水平线区分开来的?
我尝试了
errorbar(x,y,e,'--mo')
但这会同时改变它们所有的属性...
给定以下示例代码:
x = 0:pi/10:pi;
y = sin(x);
e = std(y)*ones(size(x));
figure
errorbar(x,y,e)
你是如何将这条线与水平线区分开来的?
我尝试了
errorbar(x,y,e,'--mo')
获取errorbar
对象的句柄。它有两个子元素,分别对应于数据图和误差条。然后您可以单独设置每个颜色。
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
hold on;
errorbar(x, y, e, 'r'); % // The color here will stay for the error bars
plot(x, y, 'b'); %// Here we change the color of the original function
errorbar(x, y, e, 'r', 'LineStyle', 'none');
- Dominik