필터 지우기
필터 지우기

Get real axis-limits when using "inf"

조회 수: 13 (최근 30일)
Nico
Nico 2024년 2월 16일
편집: Joe Vinciguerra 2024년 3월 5일
Hello,
I have built an App that Plots data. Now I have a button, that should set the x-Axis-Limits to default (like zooming out of my Plot). In addition to that I would like to show the actual x-axis-limits in Edit-Fields:
In my code I have implemented this by using "Inf" as limits:
app.axes.XLim = [-Inf, Inf];
Is there now a possibility to get the actual real limits, that are used in the Plot, instead of "-Inf" and "Inf"? I want to show the real Numbers in the X-min and X-max edit fields.
Best regards
Nico

채택된 답변

Joe Vinciguerra
Joe Vinciguerra 2024년 2월 16일
편집: Joe Vinciguerra 2024년 3월 5일
[Edited to include the correction noted in the comment]
From what I can tell, no, you can't get that information directly.
But it should match the min and max values of the plotted data, so a work-around might be evaluate the axes children and find the maximum values.
Alternately, you could change the Limit Mode to "auto" (app.axes.XLimMode = "auto") and the Limit Method to "tight" (app.axes.XLimitMethod = "tight"). That should provide the same visual result as setting app.axes.XLim = [-Inf, Inf], but allows you to access the automatically calculated value with something like x = app.axes.XLim
  댓글 수: 1
Nico
Nico 2024년 3월 5일
Thank you, it worked with slightly different Syntax: app.axes.XLimitMethod = "tight";

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by