reset pareto chart on App Designer

조회 수: 1 (최근 30일)
CAME18
CAME18 2023년 1월 31일
답변: CAME18 2023년 2월 1일
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?

채택된 답변

CAME18
CAME18 2023년 2월 1일
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.

추가 답변 (1개)

Voss
Voss 2023년 1월 31일
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
CAME18
CAME18 2023년 1월 31일
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.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by