Axis Labels and title not appearing in app designer
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Huw Wadkin
il 1 Set 2021
Commentato: Huw Wadkin
il 2 Set 2021
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 Commenti
Risposta accettata
Image Analyst
il 1 Set 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)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Axis Labels in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!