How to zoom in/out on an axis programmatically
Show older comments
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 Comment
John
on 17 Apr 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.
Accepted Answer
More Answers (2)
Mike Smith
on 17 Aug 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 Comment
Mohamed Abdelhamid
on 17 May 2021
Edited: Mohamed Abdelhamid
on 17 May 2021
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
shaik
on 12 Sep 2022
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
Categories
Find more on Data Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!