Making a GUI to zoom in on x-axis range

조회 수: 5 (최근 30일)
Austin Matuszewski
Austin Matuszewski 2020년 8월 3일
댓글: Arthur Roué 2020년 8월 3일
I am looking to make a GUI where the user for this program can specify a range such as June to August and it will zoom in on that range? Is this possible? Any examples are appreaciated

답변 (2개)

Cris LaPierre
Cris LaPierre 2020년 8월 3일
편집: Cris LaPierre 2020년 8월 3일
A few options I can think of.
  1. Have them use the axes toolbar. It already contains tools for zooming in and out.
  2. Have them enter the dates somehow, then use those to set the XLim properties of your axes
  3. Add 2 sliders, one that sets the min XLim value, and on to set the max XLim value
You can find a list of the properties you can set for a UIAxes here.

Arthur Roué
Arthur Roué 2020년 8월 3일
If you are in R2018a+, you can use uidatepicker component for user to chose a date.
Then refresh XLim property of your axes in uidatepicker ValueChangedFcn callback.
Here some lines to begin with
% Figure handle
hFig = uifigure()
% Axe handle
hAx = uiaxes(hFig, )
% Create date picker
hDatePicker = uidatepicker(hFig, 'ValueChangedFcn', @yourCallback);
function yourCallback(src, evt)
hAx.XLim = ..
end
  댓글 수: 2
Austin Matuszewski
Austin Matuszewski 2020년 8월 3일
does something go next to hFIG in the Axe handle?
Arthur Roué
Arthur Roué 2020년 8월 3일
Any property that you want to change. Here see documentation uiaxes
hAxe = uiaxes(parent, 'Property', Value)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by