Plot with error bars to show upper and lower bounds

I'm looking to generate a plot where the upper and lower bounds of the data are displayed above and below the mean. There is a package that allows you to plot the upper and lower boundaries of a curve, but I would like to do this for a scatter plot. To my knowledge, I can't use errorbar, because the anticipated inputs are standard deviations. What I need is something that frames the upper and lower bounds of the data. For instance if the mean = 10, the lower bound may be 7 and the upper bound may be 15. Ideally, in this hypothetical situation, I want a point at 10 and bar that extends from 7 to 15. Any suggestions?

 채택된 답변

Star Strider
Star Strider 2017년 11월 2일
The errorbar error bar limits can be anything you want them to be. They are not restricted to be standard deviations or anything else.
Example
x = 1:10; % Create Data
y = randi(9, 1, 10); % Create Data
ub = y + randi(5, 1, 10); % Create Data: Upper Bound
lb = y - randi(3, 1, 10); % Create Data: Lower Bound
figure(1)
errorbar(x, y, lb, ub, 'pg')
axis([0 11 ylim])

댓글 수: 4

I understand that you can assign whatever values you'd like as "error" using errorbar, but this solution does not work. Retaining my earlier example, if I enter: x = 1; y = 10; ub = y + 5; lb = y - 3; errorbar(x,y,lb,ub)
I get a plot with a point at 10 and error bars ranging from about 3 to 25. I want the error bars to run (in this example) from 7 to 15.
If you specify them as functions of ‘y’, they will be added to or subtracted from ‘y’, and then plotted at those points. (I did that in my example only to be certain that the random ‘lb’ and ‘ub’ values did not conflict with each other or with the value of ‘y’.)
If you want them to be plotted at specific values, simply specify those values.
Example
x = [1 2];
y = [10 11];
ub = [5 3];
lb = [3 5];
figure(2)
errorbar(x, y, lb, ub)
axis([0 3 0 20])
grid
That will plot them exactly as you want them.
Thanks for clarifying!
As always, my pleasure!
I apologise for the earlier confusion.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Errorbars에 대해 자세히 알아보기

질문:

2017년 11월 2일

댓글:

2017년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by