필터 지우기
필터 지우기

Axis Labels and title not appearing in app designer

조회 수: 46 (최근 30일)
Huw Wadkin
Huw Wadkin 2021년 9월 1일
댓글: Huw Wadkin 2021년 9월 2일
I have created an app where you can change the plot types on the axis (eg line, scatter or scatter with average) and can also choose to add a second y-axis (using yy options) or colour axis. On R2019B I did something like the below example when ever I change the plot variables as if i plotted left and right Y axis and then went back to just a left Y Axis it would keep the right Y axis there and the label, this worked perfectly (please note this isnt the exact code and just an example showing what i mean).
cla(UIAxes,'reset')
ylabel(app.UIAxes, app.LeftYAxisDropDown.Value)
xlabel(app.UIAxes, app.XAxisDropDown.Value)
plot(x,y)
Now I have moved to 2020B it wipes all the axis labels and titles even though I haven't changed the code and are still defining them after I reset the axis.

채택된 답변

Image Analyst
Image Analyst 2021년 9월 1일
xlabel() and ylabel() take a string. So after the axes handle, you have to give a string, not the index of the selected drop down list. Presumably the string you want to show is in the drop down list. Here is how to get it:
selectedIndex = app.LeftYAxisDropDown.Value;
dropDownItems = app.LeftYAxisDropDown.String; % Get all drop down items into a cell array.
axisLabel = dropDownItems{dropDownItems};
ylabel(app.UIAxes, axisLabel)
selectedIndex = app.XAxisDropDown.Value;
dropDownItems = app.XAxisDropDown.String; % Get all drop down items into a cell array.
axisLabel = dropDownItems{dropDownItems};
xlabel(app.UIAxes, axisLabel)
  댓글 수: 1
Huw Wadkin
Huw Wadkin 2021년 9월 2일
Hi Image Analyst,
I think the .Value of drop down UI is already a string, i could be wrong. After playing around with it myself for some reason the problem is fixed if I define the plot and then the labels, if I defined the labels first it wiped then the plot the labels won't appear? This didn't seem to be the case on 2019b.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by