Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to open a .fig (previously saved) in already existing UIaxes_2, UIAxes_3?

조회 수: 1 (최근 30일)
Noemie Danne
Noemie Danne 2022년 2월 27일
마감: Noemie Danne 2022년 2월 28일
I am saving a figure with app designer using the following code after the image is displaying.
The fig5 is initially plotted in app.UIAxes_3.
%
fileName5 = fullfile([Foldersavefig], ['Velocity_N_' num2str(ik_part,'00%.0f'),'_p']);
copiedAxesc5 = copyobj([c5, app.UIAxes_3], fig5);
set(fig5, 'CreateFcn', 'set(gcbo,''Visible'',''on'')');
f5 = gcf;
fa5 = gca;
f5.Resize = 'on';
fa5.Units = 'normalized'
fa5.OuterPosition = [0 0 0.8 0.8];
faf5= gcf;
set(gcf,'Visible','off')
savefig(faf5, [fileName5 '.fig']);
%
Then, I want to upload it again in the app when pushing a button and display it directly in the app.UIAxes_3.
I currently do it using openfig() function but the figure pop up first outside (in UIAxes, see picture at right) the app before to be displayed in the UIAxes_3 (using copyobj()).
cla(app.UIAxes_3);
newfig5 = openfig([fileName5 '.fig'], 'invisible');
ax5 = findobj(newfig5,'Type','Axes');
copyobj(ax5.Children, app.UIAxes_3);
% I add here the colorbar
caxis(app.UIAxes_3,[0 VELO_MAX])
c5 = colorbar(app.UIAxes_3);
colormap(app.UIAxes_3,hot)
c5.Label.String = '\alpha_{//}';
c5.Limits = [0 VELO_MAX];
hold(app.UIAxes_3,'off')
delete(newfig5)
I want to display the figure (.fig) in the UIAxes_3 directly and don't have it poping up before outside.
One option is to save the plot as .png and use imread and imshow (as followed) but it is pixelized.
file1 = imread(fullname1);
image1=im2double(file1);
imshow(image1, 'parent', app.UIAxes_3)
How to
Or how to display the .fig in the specific UIAxes_3 and prevent the figure to pop up?
  댓글 수: 1
Noemie Danne
Noemie Danne 2022년 2월 28일
Finally, the solution was to load the mat files with the variables I need and plot again the figure in the UIAxes I wanted.

답변 (0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by