MATLAB: How to apply data labels to each point in a scatter plot in MATLAB 7.0.4 (R14SP2)

datalabelsMATLABpointsscattertext;

I want to apply different data labels to each point in a scatter plot. I want to be able to place a text of my choice next to each data point in the scatter plot.

Best Answer

You can apply different data labels to each point in a scatter plot by the use of the TEXT command. You can use the scatter plot data as input to the TEXT command with some additional displacement so that the text does not overlay the data points. A cell array should contain all the data labels as strings in cells corresponding to the data points. The following is an example:
x = 1:10; y = 1:10; scatter(x,y);
a = [1:10]'; b = num2str(a); c = cellstr(b);
dx = 0.1; dy = 0.1; % displacement so the text does not overlay the data points
text(x+dx, y+dy, c);