Borrar filtros
Borrar filtros

How can I change the width of horizontal lines of error bars in ERRORBAR plot in MATLAB 2015b?

5 visualizaciones (últimos 30 días)
I am working with MATLAB 2015b and when using the ERRORBAR function, I would like to be able to change the length of the horizontal lines appearing on top and bottom of the error bars.
This question has been answered for the 2014 version of MATLAB but the solution doesn't work for the newer version of MATLAB.
Thanks in advance for your help.
Example:
x = [1 2 3 4];
y = [1 2 1 2];
dy = [0.1 0.1 0.1 0.1];
errorbar(x,y,dy)

Respuesta aceptada

André
André el 4 de Feb. de 2016
The solution is hidden in the comments of Arnaud's errorbar_tick.m.
Edit the original errorbar_tick.m, find the if-else-structure below "% Plot error bars" and replace it with the code Matt posted in the comments:
if strcmpi(flagtype,'errorbar') % ERRORBAR(...)
x = h.Bar.VertexData(1,:); % Retrieve bar xdata from errorbar
dp = length(x)/3; % 3 data points per error bar
m = 1; % Multiplier for addition/subtraction
for ii = 1:dp
m = -1*m; % Switch between subtraction and addition
x(dp+ii:dp:end) = x(ii)+m*w/2; % Change xdata with respect to the chosen ratio
end
h.Bar.VertexData(1,1:end) = x;
else
error('Please enter an ErrorBar object!');
end
Works fine for me on 2015b!
  3 comentarios
Walter Roberson
Walter Roberson el 28 de Oct. de 2016
Lichen WANG comments to Lamia Kasmi:
Your solution 'drawnow' really helps me. Thanks a lot.
Fiona Macfarlane
Fiona Macfarlane el 27 de Oct. de 2017
This works for me on 2015b, however when I save the figure (as a .fig file) the width reverts back to the previous situation. Does anyone know how to stop this. I am aware that taking screen-shots is a work around, however this is very time consuming and the quality is not great.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Errorbars en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by