I cannot get these error bars to work for the life of me
Show older comments
I have been trying to put in error bars for the last 3 hours to no avail. I keep getting the error codes "error using errorbar>check single input Xdata must be the same size as Ydata" and "error in errorbar. X = checksingleinput (x, sz, 'xData');.
Here is my code thus far.
x = categorical({'18-39','40-59','60+'});
y = [0.38850 .7817 0.4094 1.0100; 0.3026 0.0779 -0.1277 -.51500; -0.1316 -0.1213 -0.7811 -1.2379];
bar(x,y)
pos = [.376 .209 .709 1.15 .376 .209 .059 -.017 -.042 .029 -.524 -.381]
neg = [.226 -.041 .292 .155 .226 -.041 -.333 -.756 -.159 -.193 -1.25 -1.83]
title("Multivariate Association");
ylabel("Z-Score")
xlim({'18-39','60+'})
ylim([-1.50 1.50])
legend({'Group 1','Group 2','Group 3','Group 4'})
hold on
er = errorbar(x,y,neg,pos);
er.Color = [0 0 0];
er.LineStyle = 'none';
hold off
I am pretty new to Matlab, so please forgive my lack of understanding. I am currently using MATLAB R2020a
Accepted Answer
More Answers (0)
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
