I have an image in matlab and I prompt the user to select certain points on that image. So I am using the getpts method to do it. So it is working fine but I just want to represent the point the user clicked on the image with an X. However, the X is not on the point I clicked but to the side of it.
Anyone knows how to make it dead on? Here are the code that I am using and some pictures to represent it more explicitly.
Thanks you
Code:
[x_Ls y_Ls] = getpts(handles.axes1)
handles.Ls = [x_Ls y_Ls]
setappdata(0,'Lsvalue',[x_Ls y_Ls])
text(x_Ls,y_Ls,'X' , 'FontSize', 16, 'FontWeight', 'Bold', 'Color', 'k','Parent',handles.axes1);
Your issue is, that text
containing an "X" is aligned such, that its lower left corner is at [x_Ls, y_Ls]
. Things should improve if you set the HorizontalAlignment
and VerticalAlignment
to "center"
. But since fonts always define certain boundaries around the "visible" letter, you'd have a really hard time to get the "X" center to be exactly where you want it.
If you want the "X" centered right at the defined points, simply using plot
instead of text
should be easier:
plot(x_Ls, y_Ls, 'x', 'MarkerSize', 10, 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b')
Should produce an "X", right at the point you clicked on. You might have to increase the markersize...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.