Labeling coordinates of points on a graph?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mark
am 24 Jul. 2012
Kommentiert: Walter Roberson
am 6 Okt. 2016
Is it possible to label plotted points, which I have in a table/matrix, on a graph?
e.g. I have a table with 2 columns (for x and y values) and say 10 rows, and plotted thiem using the plot function, could I present the coordinates right next to the point?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Jul. 2012
for K = 1 : size(XY,1)
thisX = XY(K,1);
thisY = XY(K,2);
labelstr = sprintf('%.2f@%.2f', thisX, thisY);
text(thisX, thisY, labelstr);
end
4 Kommentare
Ibrahim Steel
am 5 Okt. 2016
for this specific example, XY should be a matrix. it can be created using the command matrix = [vectora,vectorb] if both of your vectors are column vectors (when printed, they list down). if not, you can turn them into column vecors by using ' to transpose them in the command, eg matrix = [vectora',vectorb']
Walter Roberson
am 6 Okt. 2016
Note: R2016b introduced a new function named erase() so you could end up with conflicts in your code if you name your function or script "erase"
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!