How to add Data Labels to Graph
49 ビュー (過去 30 日間)
古いコメントを表示
%% 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 件のコメント
採用された回答
Star Strider
2022 年 9 月 16 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!