How can i find the position of the origin of a Cartesian plot?

7 vues (au cours des 30 derniers jours)
Staffan Lindahl
Staffan Lindahl le 12 Déc 2013
I am trying to maintain the position of an 'edit box' in a resizeable GUI by the origin of a Cartesian plot. The position of the axes object is of course known.
How do I determine the location of the origin of the plot relative the position of the object? is there another way to find the position of the origin of the plot?
Thanks for any assistance

Réponses (1)

neil jerome
neil jerome le 7 Août 2019
i would try looking at the 'position' property of the axes against the limits; the following works for figures, and seems to for axes in GUIs from a quick check...
hh = gca;
xRange = hh.XLim(2) - hh.XLim(1);
xFract = (0 - hh.XLim(1))/xRange;
xO = hh.Position(1) + xFract*hh.Position(3);
yRange = hh.YLim(2) - hh.YLim(1);
yFract = (0 - hh.YLim(1))/yRange;
yO = hh.Position(2) + yFract*hh.Position(4);
disp(['origin at (' num2str(xO) ',' num2str(yO) ')']);

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by