Axis Labels and title not appearing in app designer
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Image Analyst
le 1 Sep 2021
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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!