my arrow is not going directly underneath my subplot. please help to adjust position its driving me not happy tried for 4 hours
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Chunru
el 3 de Mayo de 2023
Editada: Chunru
el 3 de Mayo de 2023
% 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 comentarios
Chunru
el 3 de Mayo de 2023
By trying. Remember the bottom left of the figure is (0, 0) and top right is (1,1).
Más respuestas (1)
Walter Roberson
el 3 de Mayo de 2023
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.
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!