How to zoom in/out on an axis programmatically
Afficher commentaires plus anciens
In a figure window toolbar, there are spyglass icons that let you zoom in and out on parts of an image or plot. I'd like to know how to do this programmatically.
1 commentaire
John
le 17 Avr 2015
I have a figure with the plots and axes out of screen and no scroll bar. Please I need help shrinking the plot size.
Réponse acceptée
Plus de réponses (2)
Mike Smith
le 17 Août 2016
7 votes
If you know the zoom level that you want, you can do it by setting the Xlim and Ylim on the Children of the figure handle. So if you wanted to zoom the x axis between 400 and 500 you could do: h=gcf; set(h.Children,'Xlim',[400 500]);
1 commentaire
Mohamed Abdelhamid
le 17 Mai 2021
Modifié(e) : Mohamed Abdelhamid
le 17 Mai 2021
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
shaik
le 12 Sep 2022
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!