How to add Data Labels to Graph
99 views (last 30 days)
Show older comments
%% i have 1:4 because the data is larger but I am trying to plot the first 4 values
x = 1:4;
data = final1(1:4,1);
y = data';
c = num2str(y);
errlow = [CI(1:4,1)];
errhigh = [CI(1:4,2)];
scatter(x,data)
hold on
er = errorbar(x,data(:,1),errlow,errhigh);
er.Color = [0 0 0];
er.LineStyle = 'none';
xlim([0,5]);
text(x,y,num2str(c);
I want to add a text next to each scatter plot for each y value but when I try this it plots all 4 values on each point. How can I add text to each corresponding point?
0 Comments
Accepted Answer
Star Strider
on 16 Sep 2022
I can’t run the code because of missing data.
text(x,y,compose('%.2f',c))
Use the most appropriate format specifier for whatever ‘c’ is.
If you don’t have compose, use undocumented sprintfc function with the same syntax.
.
0 Comments
More Answers (0)
See Also
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!