MATLAB Answers

0

Placing annotations at specific xy coordinates

Asked by Vance Blake on 13 Sep 2019
Latest activity Answered by Bruno Luong
on 14 Sep 2019
Just wondering but I wanted to put annotations/text boxes at specific coordinates but when I read up on the page I saw that the values of x and y in the 'dim' vector must be between 0 and 1. Im just looking for a way to place 'X's at specific xy coordinates to signify that those points are no longer being considered for my calculations?? I figured annotations would be good way to accomplish that because I wanted to avoid matlab cconsidering a plotted X as an active point and therefore valid for my calculations. If you have any work arounds or suggestions Im all ears. Thanks for the help

  0 Comments

Sign in to comment.

3 Answers

Answer by Adam Danz
on 13 Sep 2019
Edited by Adam Danz
on 13 Sep 2019
 Accepted Answer

Annotations are a pain to use unless the axes are normalized to 0:1. I see no reason why Matlab cannot allow users to specify the units in annotations which would make the tool a lot more useful.
"Im just looking for a way to place 'X's at specific xy coordinates to signify that those points are no longer being considered for my calculations"
That's much easier than anything annotation can do. Simply use the xy coordinates to plot "X"'s
hold on
plot(x,y,'rx')
If you wanted rectangles for whatever reason,
widthHeight = [.1,.1];
rectangle('Position', [x-widthHeight(1)/2, y-widthHeight(2)/2, widthHeight])

  4 Comments

Show 1 older comment
As Image Analyst said, you could always use text() which uses the same units as your data.
text(x,y,'X','HorizontalAlignment','Center','VerticalAlignment','Middle',...
'FontSize', 12,'FontWeight','bold','Color', 'r')
Yeah Im reading up on it now cause I didnt know that it existed. Feel like that link should be a related topic at the bottom of the annotation page but that's splitting hairs. Thanks again!

Sign in to comment.


Answer by Image Analyst
on 13 Sep 2019

No, not true. If you want to place annotation text onto a plot you can use text() using the x,y that's used for that plot, whatever range it might have, which can be more than 1.
Have you tried
badIndexes = .......whatever you need to do to identify "points are no longer being considered for my calculations"
hold on
plot(x(badIndexes), y(badIndexes), 'rx', 'MarkerSize', 15, 'LineWidth', 2) % Overlay big red X's

  0 Comments

Sign in to comment.


Answer by Bruno Luong
on 14 Sep 2019

There are several tool on File Exchange, such as this one

  0 Comments

Sign in to comment.