Legible error on multiple points for same x-value

1 view (last 30 days)
Nick
Nick on 12 Dec 2014
Answered: Thorsten on 12 Dec 2014
I have data points which look like this when plotted:
they represent multiple trials for the same conditions.
I want to add some sort of statistical error such as error bars or confidence bounds. However error bars are not really legible since they overlap at this scale and type.
So what are some alternatives?
This is some sample data:
Force: Height:
254.3150 15.0000
250.6990 15.0000
186.1220 15.0000
114.3150 10.0000
147.1020 10.0000
115.8110 10.0000
114.6890 10.0000
95.9890 10.0000
98.1080 10.0000
75.9160 7.5000
73.9220 7.5000
58.5950 5.0000
65.4450 5.0000
57.5920 5.0000
75.7930 5.0000
51.2340 5.0000
14.9620 2.5000
14.7120 2.5000
17.4480 2.5000
1.3730 0
1.2480 0

Answers (1)

Thorsten
Thorsten on 12 Dec 2014
Well, you have good data, that's what your overlapping errorbars show. And that's why you show them. If all your data would be like your measurements for 0, 2.5 and 7.5 you could write " Error bars were on the scale of the symbols and are not shown." But in your case you have some visible error bars for the other measurements, so I think its just fine to show them.
You could do it like this
x = X(:,2); y = X(:,1);
y_groups = {};
x_unique = unique(x(:))';
for x_u= x_unique
y_groups{end + 1} = y(x_u == x);
end
my = cellfun(@(x) mean(x), y_groups);
sy = cellfun(@(x) std(x), y_groups);
plot(x, y, '.r')
hold on
errorbar(x_unique, my, sy, 'ks')

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!