Hide trendlines on plots, via app designer

6 vues (au cours des 30 derniers jours)
Dharmesh Joshi
Dharmesh Joshi le 20 Jan 2023
Commenté : Dharmesh Joshi le 24 Jan 2023
Hi
I am using App designer to design my App. This App has multiple plots. Each plots has few trends.
Is there away to hide certain trends, either directly on the plot or via another function associated with radio or check box?
  2 commentaires
Cameron
Cameron le 20 Jan 2023
Can you show us what you're talking about?
Dharmesh Joshi
Dharmesh Joshi le 20 Jan 2023
Hi
This is my plot. I would like to be able to select any of the three trends as the only dataset to display on the plot, without any other datashet, but it has to be dynamic either an option on the plot or i can create a function via the GUI.

Connectez-vous pour commenter.

Réponse acceptée

dpb
dpb le 20 Jan 2023
Modifié(e) : dpb le 21 Jan 2023
You forgot to show us how you're creating the plot, but if you will save the line handles when plotting, then you can toggle the 'Visible' property on/off. If you'll add a 'DisplayName' property value to the lines as well, you could have a user-selectable listbox or the like to choose which to show with given name, linestyle, etc., etc., etc., ...
  3 commentaires
dpb
dpb le 21 Jan 2023
As noted, save the line handles when you plot them...you'll probably need to create another array for them with the app global struct so they are available after the callback function that draws them finishes for the user selection callback, however you choose to have the user pick which are the one(s) of interest, but you need the handles first...
temp_table=table(app.electrosensors_table{app.SelectSensorDropDown.Value}.Temperature,app.electrosensors_table{app.SelectSensorDropDown.Value}.Humidity,app.electrosensors_table{app.SelectSensorDropDown.Value}.NO2,'VariableNames',["Temperture","Humdity","Sensor"]);
corrected_model_data= app.model1_example.Model1.RegressionGP.predict(temp_table);
hold(app.UIAxes2,'off')
app.hL=plot(app.UIAxes2, ...
app.electrosensors_table{app.SelectSensorDropDown.Value}.Time, ...
app.electrosensors_table{app.SelectSensorDropDown.Value}.NO2, ...
'DisplayName','NO2');
hold(app.UIAxes2,'on')
app.hL(2)=plot(app.UIAxes2, ...
app.sensor_table_data(1).ref_timetable_period.locationA.ref_time, ...
app.sensor_table_data(1).ref_timetable_period.locationA.ref_data, ...
'DisplayName','Reference');
app.hL(3)=plot(app.UIAxes2, ...
app.electrosensors_table{app.SelectSensorDropDown.Value}.Time, ...
corrected_model_data, ...
'DisplayName','Corrected');
...
Then, whichever are the user selected to toggle, use
ixDoNotShow=resultFromUserSelectionInterfaceHoweverYouChooseToPick;
set(app.hL(ixDoNotShow),'Visible','off')
If/when the user reselects to turn back on, then simply reset 'Visible','on' again.
A uilistbox would be one way to list the 'DisplayName' property value for the three lines and let the user select one or more of those to be shown. There should be a button group or check box group with the multi-select capability as well, but I'm not all that familiar with the app designer control set and didn't see it in a quick look...
Dharmesh Joshi
Dharmesh Joshi le 24 Jan 2023
Thanks the set command works.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by