Hide trendlines on plots, via app designer

11 次查看(过去 30 天)
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 个评论
Cameron
Cameron 2023-1-20
Can you show us what you're talking about?
Dharmesh Joshi
Dharmesh Joshi 2023-1-20
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.

请先登录,再进行评论。

采纳的回答

dpb
dpb 2023-1-20
编辑:dpb 2023-1-21
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 个评论
dpb
dpb 2023-1-21
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...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by