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?

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 12 de Dic. de 2016

8 votos

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.

Más respuestas (0)

Categorías

Productos

Versión

R2016b

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by