How to zoom in/out on an axis programmatically
조회 수: 94 (최근 30일)
이전 댓글 표시
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
John
2015년 4월 17일
I have a figure with the plots and axes out of screen and no scroll bar. Please I need help shrinking the plot size.
채택된 답변
Youssef Khmou
2013년 5월 22일
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
Kyle Chappell
2017년 1월 11일
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.
추가 답변 (2개)
Mike Smith
2016년 8월 17일
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
Mohamed Abdelhamid
2021년 5월 17일
편집: Mohamed Abdelhamid
2021년 5월 17일
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
shaik
2022년 9월 12일
ax = gca;
ax.XLim = [lowerxvalue upperxvalue];
ax.YLim = [loweryvalue upperyvalue];
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!