How do I add error bars to scatter plots?

8 views (last 30 days)
I have a scatter plot and want to add error bars. The "errorbar" function is not giving me correct results. How do I do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Dec 2016
The function "scatter" does not currently support error bars. However, these can be achieved by overlaying the results of "errorbar" on top of "scatter", like so:
>> x = [1,2,3];
>> y = x.^2;
>> scatter(x,y);
>> axis([0,4,0,10]);
>> hold on;
>> err = ones(size(x));
>> errorbar(x, y, err, 'LineStyle','none');
An enhancement request has been submitted for this feature so it will be considered for future releases of MATLAB.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!