Reference Axes Positions in a Plot

3 views (last 30 days)
Allen Hammack
Allen Hammack on 8 Dec 2021
Commented: Allen Hammack on 10 Dec 2021
I have a plot where I set the axes positions explicity. My code for this is:
ax_left = gca;
ax_left.Position = [0.05 0.05 0.89 0.85];
I'm creating annotations that I'm trying to define locations for explicity. My code for definining the locations for the annotations is:
AxesHandle = findobj(gca,'Type','axes');
plot_proto_wse_hawser_trans.x_min = AxesHandle.Position(1);
plot_proto_wse_hawser_trans.y_min = AxesHandle.Position(2);
plot_proto_wse_hawser_trans.x_max = AxesHandle.Position(1) + AxesHandle.Position(3);
plot_proto_wse_hawser_trans.y_max = AxesHandle.Position(2) + AxesHandle.Position(4);
When I create the annotations, The locations use the ax_left.Position values instead of the AxesHandle Position values. Can someone tell me how to reference the AxesHandle Position values?
  2 Comments
Allen Hammack
Allen Hammack on 10 Dec 2021
Thank you for the information, Dave B!
I looked through my code and noticed that after I used ax_left.Position, I added things to the plot that adjusted where the axes are located. Those changed were throwing me off. I moved ax_left.Position, and now everything is working.
Thank you!

Sign in to comment.

Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by