Effacer les filtres
Effacer les filtres

How to display a saved .fig file in uiaxes appdesinger?

13 vues (au cours des 30 derniers jours)
taimour sadiq
taimour sadiq le 28 Nov 2023
Commenté : Walter Roberson le 28 Nov 2023
i have some .fig plot save in my folder and i want to display them in UIAxes Appdesinger.. My code is
Path = 'C:\Folder\';
My_Fig = dir(fullfile(Path,'*.fig');
% Till here i have succesfully read all figures, now i want to display first figure in uiaxes appdesinger
imshow(My_Fig(1),'parent',app.UIAxes); % Not Works >> i have also tried openfig, imread etc

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Nov 2023
You cannot do that. A fig file is a saved figure or saved uifigure. Saved figures and uifigures are windows with attached behavior. You cannot display a complete window with behavior inside part of another window.
What is potentially possible is to copy objects from an axes in the figure, copying them into the new figure of uifigure. This will not copy all of the behavior (but might copy some of it). It risks not copying colorbars or legends or annotations. It also has a problem if the saved figure has more than one axes.
  2 commentaires
Dyuman Joshi
Dyuman Joshi le 28 Nov 2023
OP can use exportgraphics to save the contents of the graphics object and then use imshow.
Walter Roberson
Walter Roberson le 28 Nov 2023
ProjectPath = 'C:\Folder\';
My_Figs = dir(fullfile(ProjectPath,'*.fig');
if isempty(My_Figs); error('No fig files in "%s"', ProjectPath); end
figfilename = fullfile(My_Figs(1).folder, My_Figs(1).name);
fig_to_copy = openfig(figfilename);
ax_to_copy = fig_to_copy.CurrentAxes;
After that you start needing to get into the code I posted at https://www.mathworks.com/matlabcentral/answers/262265-duplicating-an-imshow-image-into-a-new-figure-without-using-imshow#comment_332459 to copy the children of ax_to_copy, and to extract properties from the axes, filter the property names down to the ones that are settable, then copy the other properties to the new axes.
If the source axes to copy is already a uiaxes then it is a lot easier to copy the existing axes into the uifigure using copyobj() and then set the Position property of the newly-copied axes to the position that you wanted the uiaxes to be displayed at.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by