my arrow is not going directly underneath my subplot. please help to adjust position its driving me not happy tried for 4 hours
1 次查看(过去 30 天)
显示 更早的评论
So I have a subplot in my code and i want to draw a large red arrow horizontal pointing in the positive x direction directly under neath the subplot. However, nothing I do puts the arrow in the correct place. I use gef function to find the position of the subplot and then try to match the arrow to the position output but the arrow just won't move to the correct area, can someone please help me with this seemingly trivial thing that is actually not trivial at all. The arrow is not arrowing.
How can i get an arrow using annotate (or anything else) directly beneath my subplot like where the x label is. Thanks!
% Plot the circle
subplot(3, 4, 3);
theta = linspace(0, 2*pi, 100);
x = centerp(1) + radiusp*cos(theta);
y = centerp(2) + radiusp*sin(theta);
plot(x, y, 'LineWidth', 2);
% Add X axis label in bold letters with color-coded text
xlabel('\bf BLOOD FLOW: left to right');
annotate(..)
0 个评论
采纳的回答
Chunru
2023-5-3
编辑:Chunru
2023-5-3
% Plot the circle
subplot(3, 4, 3);
theta = linspace(0, 2*pi, 100);
centerp = [0 0]; radiusp=1;
x = centerp(1) + radiusp*cos(theta);
y = centerp(2) + radiusp*sin(theta);
plot(x, y, 'LineWidth', 2);
% Add X axis label in bold letters with color-coded text
xlabel('\bf BLOOD FLOW: left to right');
% The annotation coordinates are normalized figure units.
annotation('arrow', [.5, .7], [0.6, 0.6], 'Color', 'red')
% Another method
figure
subplot(3, 4, 3);
plot(x, y, 'LineWidth', 2);
% Add X axis label in bold letters with color-coded text
xlabel(["\bf BLOOD FLOW: left to right", "\color{red}\fontsize{32}\rightarrow"]);
3 个评论
更多回答(1 个)
Walter Roberson
2023-5-3
unfortunately the coordinates for annotate() are relative to the figure (or possibly the container if you use uipanel, I would have to check that). In particular the coordinates are never data coordinates. And that means that as soon as you change sizes of anything or scroll or zoom the coordinates might be invalid.
To get around this there are some file exchange contributions that will translate between data coordinates and figure coordinates. Some of them provide tools to make it easier to deal with changes in position.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!