How to zoom in/out on an axis programmatically
95 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
John
il 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.
Risposta accettata
Youssef Khmou
il 22 Mag 2013
hi,
There is a function "zoom" with the following options :
zoom on
zoom off
zoom out
zoom reset
zoom xon
zoom yon
zoom(factor)
zoom(fig, option)
h = zoom(figure_handle)
9 Commenti
Kyle Chappell
il 11 Gen 2017
hObject is the object handle. It's passed as a default argument when accessing the callback function of uicontrol objects. For instance, if you have a uibutton, e.g. 'Go', 'Save', 'Next', the handle to the button object will be passed. This gives you access to the object properties like Position, String, buttonDownFcn, etc. and allows you to access their values or edit them.
This may not always be the case, I'm not an expert, but I've run into this a lot when building GUIs, whether using GUIDE or not.
To ensure the accuracy of what I've said on your own, I suggest you build something with GUIDE, set a breakpoint after a function calling hObject and using get(hObject) to view the accessible properties. Using get(handles.pushbutton1), for example, should be the same as get(hObject) when used in pushbutton1's callback function. I can't be sure, I don't have MATLAB open in front of me right now.
Feel free to correct me if I'm wrong. I'm always open to learning something new.
Più risposte (2)
Mike Smith
il 17 Ago 2016
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 Commento
Mohamed Abdelhamid
il 17 Mag 2021
Modificato: Mohamed Abdelhamid
il 17 Mag 2021
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
shaik
il 12 Set 2022
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Exploration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!