Drawing Error bars with specific linestyle
15 views (last 30 days)
Show older comments
Savio Sciancalepore
on 2 Aug 2016
Hello to everybody, does anyone know a way for drawing errorbars with the same style of the data line?
For example, when using:
d = errorbar(x,y,y_error,'Linestyle', ':');
MATLAB returns the data lines in dotted style, while the bars in each of the points are straight. What if I want also the bars in the dotted style?
0 Comments
Accepted Answer
More Answers (1)
dpb
on 2 Aug 2016
Set the 'linestyle' property of the second errorbar series object obtained from the hggroup handle returned by errorbar -- from the example
>> X = 0:pi/10:pi;
Y = sin(X);
E = std(Y)*ones(size(X)); % the example data...
>> hE=errorbar(X,Y,E); % save handle this time
>> get(hE,'type') % what is the handle?
ans =
hggroup
>> hEC=get(hE,'children'); % and get the objects
>> get(hEC,'type') % and what are they???
ans =
'line'
'line'
>>
Aha! they're the two lines...take a chance the errorbars are the second; data the first...
>> set(hEC(2),'linestyle',':')
>>
Unfortunately, TMW didn't implement being able to set both 'linestyle' properties from the UI named parameter. If they'd accept a cell array of strings, could apply them to the two objects if present but didn't so you have to set the property separately after locating the proper object handle.
0 Comments
See Also
Categories
Find more on Errorbars in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!