Reference Axes Positions in a Plot
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dave B
2021-12-9
The way you've written the code, plot_proto_wse_hawser_trans uses the Poisition values from AxesHandle. You didn't include the annotation code, but the positions you've captured are indeed the x,y or the lower left corner and upper right corner of AxesHandle.
However, AxesHandle is the current axes. There's no difference between:
ax = gca;
and
ax = findobj(gca,'Type','axes');
They both return the current axes. findobj looks at an object and all its descendents to a specified type, but you've pointed it at gca, so it's an exact match.
Maybe you could expand on which axes you're trying to find?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!