Vertical error bars disappear on logy plot

7 visualizaciones (últimos 30 días)
Karellen
Karellen el 9 de Mzo. de 2021
Respondida: Walter Roberson el 9 de Mzo. de 2021
I made a scatter plot then added error bars:
err = errorbar(statsx, avgs, error, 'LineWidth', 2, 'CapSize', 12);
err.LineStyle = 'none';
err.Color = 'b';
I then set the y axis to log:
set(gca, 'YScale', 'log')
... and about half of the negative error bars disappear. The bars which disappear are consistent whenever I re-run the script. When I set the axis back to linear, all bars re-appear.
What could be happening?

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
When you use Yscale log, then:
  • if all of the y coordinates are negative, a warning is given and plotting proceeds as if the values were positive; otherwise
  • no line is drawn to any vertex that has a negative y coordinate
  • no face is drawn for any surface or patch area that has a negative y coordinate
bar() plots are patch() objects, so if a bar has any negative y coordinates, that bar will not be drawn, not even if you ylim a positive lower bound. MATLAB will not attempt to find the intersection of the face and the ylim / xlim and draw only that part: the entire face will be omitted, same as if it had a coordinate that was infinite or nan.
Error bars themselves might have the limits drawn as line objects, so you can end up with the situation where an reference line is drawn (because its ends are positive) for a face that is not drawn (because it has a negative y coordinate somewhere)

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties 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