How do I add error bars to scatter plots?

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

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)

Products

Release

R2016b

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!