Errorbars do not have horizontal lines

When I plot the errorbars on my function, I am only getting the vertical lines and the circle at the center. How do I get the horizontal lines at the top and bottom as well??

2 commentaires

Geoff Hayes
Geoff Hayes le 11 Juin 2014
Eric - you may need to provide more information. What is the code you are using to plot your errorbars? (Presumably the errorbar function.) Perhaps attach an image of what you see, and one of what you would like to see.

Connectez-vous pour commenter.

 Réponse acceptée

Star Strider
Star Strider le 11 Juin 2014

1 vote

We need to see the code you use to create your plot. I couldn’t find anything in Errorbarseries Properties that seem to affect the way the error bar horizontal lines are displayed. There seems to be no way to turn them on or off or scale them (not that I’d want to, since I like them the way they are).
They might be there but too small for you to see if your x-data are closely spaced or other data scaling problems are interfering with them. Click on the magnifying glass symbol in the figure window and see if enlarging the figure reveals them. (I recently needed to do this to be sure the arrowheads in a ‘quiver’ plot were actually there.)
Note to MathWorks — It would be nice to be able to display horizontal error bars as well.

3 commentaires

semilogx(p,A_avg, p, B_avg)
hold on
errorbar(p,A_avg,A_std, 'ko')
hold on
errorbar(p, B_avg, B_std, 'ko')
‘that's the string of code that i have producing the graph. I'm guessing the semilogx as the plot command probably impacts the errorbar formation as the horizontal bars show up when i use "plot" instead of "semilogx" as the command.’
----------------
Eric — Unlike plot axis properties that allow XScale (and the other axes) to have linear or log scaling, errorbar does not. If you want a logarithmic x-axis, you will have to take the log of ‘p’, then set the XTickLabel property to display the base 10 logarithm of the XTick data if you want to use errorbar and a logarithmic x-axis. I’ve not actually done that, but I suspect it wouldn’t be too difficult. It will probably be easier if you use the log10 function rather than log.
Eric
Eric le 12 Juin 2014
I see what you're saying and that definitely makes sense. For simplicity's sake, though, I just ended up accepting the fact that my errorbars would only have vertical lines. Error margin is very small, anyway, so having horizontal bars might look a little silly in retrospect.
Star Strider
Star Strider le 12 Juin 2014
My pleasure!
I agree. If the errors are small, the actual data or regression line can get lost. I like errorbar and use it often, but an alternative I sometimes use is to plot x and the upper error limits, and x and the lower error limits. That gets across the idea and avoids some of the visual distraction of closely-spaced error bars.

Connectez-vous pour commenter.

Plus de réponses (1)

Eric
Eric le 11 Juin 2014
semilogx(p,A_avg, p, B_avg)
hold on
errorbar(p,A_avg,A_std, 'ko')
hold on
errorbar(p, B_avg, B_std, 'ko')
that's the string of code that i have producing the graph. I'm guessing the semilogx as the plot command probably impacts the errorbar formation as the horizontal bars show up when i use "plot" instead of "semilogx" as the command.

Catégories

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by