How to add Data Labels to Graph
97 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pushti Shah
el 16 de Sept. de 2022
Respondida: Star Strider
el 16 de Sept. de 2022
%% 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 comentarios
Respuesta aceptada
Star Strider
el 16 de Sept. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Discrete Data Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!