Placing annotations at specific xy coordinates
221 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Adam Danz
2019 年 9 月 13 日
編集済み: Adam Danz
2019 年 9 月 13 日
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])
その他の回答 (3 件)
Olle Trollberg
2023 年 8 月 29 日
I recently ran into this and here is a simple way to get around it using some anonymous functions to do rescaling.
Works at least in 2022b
plot(x,y) % Create whatever plot
ax = gca;
% Define helper funcitons to normalize from axis coordinates to normalized position in figure.
xnorm = @(x)((x-ax.XLim(1))./(ax.XLim(2)-ax.XLim(1))).*ax.InnerPosition(3)+ax.InnerPosition(1)
ynorm = @(y)((y-ax.YLim(1))./(ax.YLim(2)-ax.YLim(1))).*ax.InnerPosition(4)+ax.InnerPosition(2)
annotation('textarrow',xnorm(x_in_axis_coordinates),ynorm(y_in_axis_coordinates),'string','Arrow Text');
0 件のコメント
Image Analyst
2019 年 9 月 13 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!