Standardising errorbar whiskers
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi
I am using a set of data to construct a plot of errorbars with associated standard errors and whiskers for row=0:5;
for col = 0:2;
x=data(1+row,1+col);
y=data(1+row,4+col);
e=data(1+row,7+col);
if row==0;
shape='sk';
elseif row==1;
shape='dk';
elseif row==2;
shape='^k';
end
subplot (3,1,1)
errorbar(x,y,e,shape, 'MarkerFaceColor','k','MarkerSize', 8, 'LineWidth',1),ylim ([0 1]),xlim ([0 3.5]);
hold on
box('off');
end
end
Unfortunately the whisker ends are not a uniform length. As can be seen in this example. I have added a highlight to emphasise what I am referring to.
Either I would like to stop this increase happening or set the size of the whisker plot ends.
Please help (at the wits end with my whiskers)
Stephen
댓글 수: 1
Oleg Komarov
2011년 8월 24일
We don't have data and row to run your example and from the code nothing abnormal should happen.
답변 (3개)
Daniel Shub
2011년 8월 26일
Is your xscale linear or log?
get(gca, 'xscale')
I have had problems with errorbar widths and log scales. If you are using a log scale, you could use
errorbar(log(x), ...
and a linear scale. The new numbers shouldn't be a problem since you are replacing the tick labels with text anyways.
댓글 수: 0
Oleg Komarov
2011년 8월 29일
The length of the horizontal line for the whiskers is proportional to [xdata(1) xdata(end)] the range on the x-axis.
In brief, if you have 5 points and their position on the x-axis is 1, 2, 3, 4, 5 the horizontal line will be proportional to 4.
You get different lengths because you plot several groups of points and the range is not assured to be constant.
There are two ways to get the same length for the horizontal line:
- Force the range for each group to be constant by adding fake points to each group such that xdata(end) - xdata(1) = k. In order for these fake point to not appear on the graph, simply set some y-values out of the ylim
- Modify manually the whiskers
To visualize the whiskers after you finished plotting one graph:
h = findall(gca,'Type','Line');
plot(get(h(2),'Xdata'),get(h(2),'Ydata'))
Good luck
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!