考虑下面的示例代码:如何分离颜色errorbar MATLAB
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 MATLAB
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
真棒,这是更简单的一个linespec魔神 – user1234440
在2014b错误栏对象没有子女anymore。规避这一点的一种(丑陋的)方法是用不同的颜色再次绘制功能。实际上,这种功能在旧颜色的功能上以新颜色绘制。
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的lineplot都:'errorbar(X,Y,E, 'R', '的LineStyle' ,'none');' – Dominik
+1可运行代码 –