Standardising errorbar whiskers
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Oleg Komarov
am 24 Aug. 2011
We don't have data and row to run your example and from the code nothing abnormal should happen.
Antworten (3)
Daniel Shub
am 26 Aug. 2011
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 Kommentare
Oleg Komarov
am 29 Aug. 2011
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 Kommentare
Siehe auch
Kategorien
Mehr zu Errorbars finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!