gplotmatrix does not show graphics correctly on app designer app

Hi,
I have tried to use gplotmatrix in 2 formats shown below in my app. Both result to bunch of error messages in matlab side and graph which does not have histograms on diagonal. Tried also to put variable names on diagonal, but that feature does not work either.
gplotmatrix(app.Panel_2,app.Predictors,[],[],[],[],[],[],'hist',app.PredictorVarNames);
gplotmatrix(app.UIAxes4,app.Predictors,[],[],[],[],[],[],'hist',app.PredictorVarNames);
Anybody know what might be going on ?
I have separate matlab script which I used to test the variables. That one draws the figure perfectly.
I also tried to fix the gplotmatrix on the panel with set command -
h=gplotmatrix(CmatData,[],[],[],[],[],[],'hist',CorMatNames);
set(h,'Parent',app.Panel_2);
it may not be possible or the way I am trying to do this is wrong. The lines above, when used in app, draws the gplotmatrix as pop up window correctly.
Any help - highly appreciated ...
Antti Heikkinen

 채택된 답변

Adam Danz
Adam Danz 2021년 5월 24일
편집: Adam Danz 2021년 5월 24일
Cause of the error
Always share the entire error message when asking how to fix the error.
For now I'll assum you received an error similar to this one (R2021a),
Error using matlab.ui.Figure/set
Functionality not supported with figures created with the uifigure function.
Error in gplotmatrix (line 401)
set(figparent,'NextPlot','replace')
Error in MyFunction (line 15)
gplotmatrix(uip,X,[],group,color,[],[],[],'grpbars',xnames)
The second line indicates that some process that gplotmatrix relies on does not accept figtures created with uifigure which is the figure-type used in AppDesigner.
If you received a different error message, add that to your question or as a comment under your question and we can work from there.
Workaround
One workaround would be to produce the gplotmatrix in a panel within an independent figure and then move the panel to your app figure after its rendered.
Basic steps,
% Produce a UIFigure with a UIPanel (this will already exist in your app)
app.UIFigure = uifigure();
app.UIPanel = uipanel(app.UIFigure);
% Produce gplotmatrix in an external, hidden figure
tempfig = figure('visible','off');
cleanupFig = onCleanup(@()delete(tempfig));
tempUIPan = copyobj(app.UIPanel, tempfig);
data = load('fisheriris.mat');
gplotmatrix(tempUIPan,data.meas,[],data.species);
drawnow
% Move invisible
h = copyobj(tempUIPan.Children, app.UIPanel);
delete(tempfig) % Delete hidden figure

댓글 수: 4

Hi Adam,
Sould have though addint the error messages. Anyways - Yes I am getting same error messages than You.
BR,antti
Then the short workaround I demonstrated should work for you. Have you tried it?
This worked - Million thanks Adam !
Oh, good. I wasn't sure whether the gplotmatrix options you were using (the hist option) would affect the workaround or not.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Geographic Plots에 대해 자세히 알아보기

질문:

2021년 5월 24일

댓글:

2021년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by