Filter löschen
Filter löschen

reset pareto chart on App Designer

3 Ansichten (letzte 30 Tage)
CAME18
CAME18 am 31 Jan. 2023
Beantwortet: CAME18 am 1 Feb. 2023
I am developing a GUI with App Designer. One of its components is a pareto chart which is created with the function
pareto(app.MassParetoChart,masas,names_comps,1)
where the app.MassParetoChart is an App Designer UIAxes. Whenever the user inputs data is modified and the user produces a new pareto chart with the new input data, first the following commands are employed to reset and clean the UIAxes:
cla(app.MassParetoChart); clf(app.MassParetoChart); reset(app.MassParetoChart);
% Replot with the new data:
pareto(app.MassParetoChart,masas,names_comps,1)
However, after a few runs, the plot somehow is not entirely reseted and older axes apparently remain as can be seen in this figure
Trying the variant:
cla(app.MassParetoChart,"reset"); clf(app.MassParetoChart,"reset"); reset(app.MassParetoChart,"reset");
also presents the same issue appart from opening a new figure window outside of the App Designer app window:
What would be the right approach to correctly address this issue?

Akzeptierte Antwort

CAME18
CAME18 am 1 Feb. 2023
Update:
The correct reset of the pareto( ) plot can be done as follows:
Generating the figure and storing the objects
[par_charts,par_axes] = pareto(app.MassParetoChart,masas,names_comps,1);
app.figParetoObjs.par_charts=par_charts;
app.figParetoObjs.par_axes=par_axes;
Then, whenever it is required to plot new results and
Then, whenever it is required to plot new results and
cla(app.MassParetoChart);
reset(app.MassParetoChart);
delete(app.MassParetoChart.Children)
if ~(isempty(app.figParetoObjs.par_axes))
delete(app.figParetoObjs.par_axes(2));
end
I am not sure if all the commands (cla(),reset(),delete()) are required but some or all of them are doing the trick.

Weitere Antworten (1)

Voss
Voss am 31 Jan. 2023
pareto creates a new axes and returns the two axes as the second output. You can store that new axes and cla(_,'reset') it along with your original uiaxes.
To demonstrate, step through this code in your command line:
f = uifigure('AutoResizeChildren',false);
ax = uiaxes(f);
[p,new_ax] = pareto(ax,rand(10,1)); % new_ax contains the original uiaxes ax and the new axes
cla(ax,'reset')
cla(new_ax(2),'reset')
Then adapt for use in your app.
  1 Kommentar
CAME18
CAME18 am 31 Jan. 2023
Hello. Thanks for replying.
I am trying the following to generate the figure:
[par_charts,par_axes] = pareto(app.MassParetoChart,masas,names_comps,1);
app.figParetoObjs.par_charts=par_charts;
app.figParetoObjs.par_axes=par_axes;
Then, whenever the inputs are changed and replotting is required, the figure is reset with these commands:
cla(app.MassParetoChart,"reset");
if ~(isempty(app.figParetoObjs.par_axes))
cla(app.figParetoObjs.par_axes(2),"reset");
end
Unfortunately, the pareto( ) behaves erratically, not even showing the actual figure:
As an alternative:
Whenever the inputs are changed and replotting is required, the figure is reset with these commands:
cla(app.MassParetoChart);
if ~(isempty(app.figParetoObjs.par_axes))
cla(app.figParetoObjs.par_axes(2));
end
The situation is basically the same as the one described on the original post.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by