plotting side-by-side error bars and data points
Show older comments
Hello Experts,
I would be much grateful if you could help me with the following matter. I would like to create a plot similar to the one shown below. 

Specifically, I would like to have the following features:
- Data points should be displayed as purple solid cirles (the shape, colors don't matter) and they are connected by line segments.
- Next to each data point, I want to place 2 error bars, side-by-side. Each error bar should have lower and upper bounds, as well as the center point.
- In terms of labelling, each data point and the 2 side-by-side error bars should be grouped together with a single label.
Here is my code, but it does not produce the desired plot.
hold on
x = 1:1:4;
xlim([0 5])
ylim([0 5])
data_points = [4 3 2 3];
plot(x,data_points,'s','LineWidth',6)
xlabel('Conditions','FontSize',16)
xticklabels({'label 1','label 2','label 3','label 4'})
ax = gca;
ax.FontSize = 16;
title('ABC','FontSize',16)
% -------- error bar 1 ----------------
y = [3.5 3.2 1.7 2.5];
yneg = [0.1 0.2 0.1 0.3];
ypos = [0.2 0.1 0.3 0.1];
e = errorbar(x,y,yneg,ypos,'*','MarkerSize',10);
e.LineWidth = 2;
% -------- error bar 2 ----------------
y = [3.1 2.7 2.1 3.2];
yneg = [0.1 0.2 0.1 0.3];
ypos = [0.2 0.1 0.3 0.1];
e = errorbar(x,y,yneg,ypos,'*','MarkerSize',10);
e.LineWidth = 2;
hold off
Accepted Answer
More Answers (0)
Categories
Find more on Line 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!
