how to refrech XticksLabel when i zoom a graph in an app

조회 수: 13 (최근 30일)
patrice boisset
patrice boisset 2023년 2월 16일
댓글: patrice boisset 2023년 2월 17일
Good morning
I'm using datestr for printing time on th xlabel axis but if i zoom all the label became wrong.
I've got the write command to refresh the X labels but I think there is a mean to create a callback when the zoom is activated.
I'm in a app designed figure but if it's possible in classicle figure i'm intersted to.
regards

채택된 답변

Steven Lord
Steven Lord 2023년 2월 16일
Rather than calling datestr or datetick I recommend plotting using a datetime array as your X data.
v = 0:10;
y = v.^2;
tenDays = datetime('today') + days(v)
tenDays = 1×11 datetime array
16-Feb-2023 17-Feb-2023 18-Feb-2023 19-Feb-2023 20-Feb-2023 21-Feb-2023 22-Feb-2023 23-Feb-2023 24-Feb-2023 25-Feb-2023 26-Feb-2023
plot(tenDays, y)
As you zoom in on the axes MATLAB will automatically update the tick labels. If you want to customize the format used to display the datetime data you can use the xtickformat function to do so.
  댓글 수: 1
patrice boisset
patrice boisset 2023년 2월 17일
Hello Steven
Thank you for the answer. This solution is very convinient while there is only one plot in the same axis but in my case there is different lines with diferents time vector and in that case the zoom made strong Xscale because of the Xlabels that don't folow.
Below the second graph has been zoomed between 12 and 13 o'clock and the plot has been done with datetime solution.
So I went back to my old manner and i'm steel interested for the way to code a callback after a zoom in an app and or a figure.
Thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by