- Define a custom axes size so that knowing your XLim and YLim you could get the aspect ratio you want
- Calculate the position, given the aspect ratio, of the white square within the axes object
Axes' position after adjusting data aspect ratio
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When adjusting the data aspect ratio of axes, the visual display of the axes changes, but not their 'Position'. Is it possible to find the equivalent position of the adjusted/visible axes? Needed for e.g. annotations and for positioning new axes/subplots in the same figure.
Here is an illustration (black - aspect adjusted, red - position):
figure;
axpos1 = get(gca,'Position')
set(gca,'DataAspectRatio',[1 1 1]);
axpos2 = get(gca,'Position')
axes('Position',axpos2,'Color','None','XColor','r','YColor','r');
0 commentaires
Réponse acceptée
José-Luis
le 3 Jan 2013
Modifié(e) : José-Luis
le 3 Jan 2013
What happens is that the axes object is not actually the white square you see. If you go to the property editor and click on both axes you will see that both axes actually have the same size.
If you want to keep the Position so your annotation make sense, you could do it in two ways:
However, maybe someone has done this in the file exchange but I can't remember off the top of my head.
0 commentaires
Plus de réponses (2)
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!