MATLAB: Changing the location of num2str

graphMATLAB

Hi, I am using the following to illustrate the index of the (x,y) location inside a polygon. text(x(i),y(i),num2str(i) With the above code I get the numbers exactly on the (x,y) point. Does someone know how to change that location?

Best Answer

Add an offset to the x (and/or y) location:
d = 0.01;
text(x(i)+d,y(i),num2str(i))
Remember that x and y are data units: you will need to pick a value of d that makes sense for your data.