Plotting multiple scatter points against yticklabel
Show older comments
Hi, I want to plot my mean and stnadard deviation by I can't do this if I plot against yticklabel so I tried to make 2 axis and it hasn't worked out.
I would like U1 to be next to my purple and A1 label to be next to my blue points
I could use xline but then it becomes a bit confusing as the lines go into both scatter data .
I also don't want each scatter point labelled as they are collectively 2 sets of points. (legend)

%% Figure 1
f1=figure(1);
set(f1,'color','w');
yyaxis left
set(gca,'YTickLabel', {'U1'; 'A1'});
label1 = {'U1'}
label2 = {'A1'}
yyaxis right
set(gcs,'Ytick',[]);
plot1 = scatter(U1,1,'o','color', [0.7 0 1],'markerfacecolor',[0.7 0 1],'markeredgecolor',[0.7 0 1],'MarkerFaceAlpha',0.5);
hold on
plot2 = scatter(A1,2,'o','color',"b",'markerfacecolor', "b",'markeredgecolor', "b",'MarkerFaceAlpha',0.5);
hold on
meanA = scatter(Ubar,1,'o','color','r','markerfacecolor','r','markeredgecolor','r','MarkerFaceAlpha',0.7);
meanU = scatter(Abar,2,'o','color','r','markerfacecolor','r','markeredgecolor','r','MarkerFaceAlpha',0.7);
hold on
plot([Abar Abar],[1.5 3],'r','LineStyle','--','LineWidth',1);
plot([Ubar Ubar],[0 1.5],'r','LineStyle','--','LineWidth',1);
%Confidence intervals for means
plot([0.0219 0.0219],[1.5 3],'r','LineStyle','--','LineWidth',0.5);
plot([1.0113 1.0113],[1.5 3],'r','LineStyle','--','LineWidth',0.5);
plot([0.1305 0.1305],[0 1.5],'r','LineStyle','--','LineWidth',0.5);
plot([0.2685 0.2685],[0 1.5],'r','LineStyle','--','LineWidth',0.5);
%use error bars to plot std
errorbar([Ubar],[1],Usigma,'horizontal','LineWidth',1)
errorbar([ Abar],[2],Asigma,'horizontal','LineWidth',1)
ylim([0 3]);
xlabel('OD');
hold off
Accepted Answer
More Answers (0)
Categories
Find more on Annotations 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!