How to display a saved .fig file in uiaxes appdesinger?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
taimour sadiq
il 28 Nov 2023
Commentato: Walter Roberson
il 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
0 Commenti
Risposta accettata
Walter Roberson
il 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 Commenti
Dyuman Joshi
il 28 Nov 2023
Walter Roberson
il 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!