reset pareto chart on App Designer

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?

 Accepted Answer

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.

More Answers (1)

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 Comment

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.

Sign in to comment.

Products

Release

R2022a

Asked:

on 31 Jan 2023

Answered:

on 1 Feb 2023

Community Treasure Hunt

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

Start Hunting!