<code>M = rand(10,2); x = 1:size(M,1); plot(x, M(:,1), 'b.-', x, M(:,2), 'g.-') legend('M1', 'M2') for i=x text(i+0.1, M(i,1), sprintf('%.2f', M(i,1)), 'fontsize',7, 'color','b' ); text(i+0.1, M(i,2), sprintf('%.2f', M(i,2)), 'fontsize',7, 'color','g' ); end </code>
Alternatively, you can use:
<code>datacursormode() </code>
which will enable the user to just point and click on points to see the data label.
You can label each axis with the function:
<code>xlabel('label') ylabel('label') </code>
These can also take cell arguments, where each row is a new line. That’s handy for showing units. Labeling each point on the figure can be done as so:
<code>for i=1:length(M) text(M(i,1),M(i,2),'Label Text') end </code>
The label text can also be a string variable that you can edit with sprintf and make special strings for each point.