Exporting specific panels from Appdesigner

I have got a gridlayout with 4 panels and I would like to export specific panels to either a png, ppt or pdf. These panels have a tiledlayout and have several plots in them. Hence, I would just like to "screenshot" a specific panel and export it elsewhere.

 Réponse acceptée

Sai Teja G
Sai Teja G le 25 Août 2023

0 votes

Hi Suhas,
I understand that you want to save the plots of panels in tiledlayout seperately.
So for this you do not need to screenshot each plot, instead you can use the below feature from MATLAB to save or export plot images seperately.
Hope it helps!

3 commentaires

Suhas Ramanan
Suhas Ramanan le 27 Août 2023
Hi Sai, thanks for your tip! I took notice of this as well. This works but I was thinking of a programmatic way of being able to export a entire panel of plots into powerpoint. I would not want to manually click and save these plots.
In other words, I would like to export a panel of plots in its current format (see below) into powerpoint, instead of individual plots.
Do let me know if you have a solution to this!
Thanks
Mario Malic
Mario Malic le 27 Août 2023
exportgraphics is the function to do it.
Thanks for the reference Mario!
I managed to create a code:
function ExportButtonPushed(app, event)
% Create a folder to store the exported images
exportFolder = 'ExportedPanels';
mkdir(exportFolder);
for i = 1:4
try
% Create a temporary figure
tempFig = figure('Visible', 'off');
% Get the handle to the current panel (app.Panel_1, app.Panel_2, etc.)
panelHandle = app.(['Panel_' num2str(i)]);
% Copy the UI panel's content to the temporary figure
copyobj(panelHandle.Children, tempFig);
% Create a filename for the exported image
imageFileName = fullfile(exportFolder, ['Panel_' num2str(i) '.png']);
% Capture and export the content of the temporary figure
exportgraphics(tempFig, imageFileName, 'Resolution', 800, 'BackgroundColor','none', 'ContentType','vector');
% Close the temporary figure
close(tempFig);
% Provide feedback to the user
disp(['Panel ' num2str(i) ' screenshot saved as: ' imageFileName]);
catch exception
% Display an error message
disp(['Error capturing Panel ' num2str(i) ': ' exception.message]);
continue; % Move on to the next panel
end
end
However, one of the panels gives me an error: Object Copy of Axes with multiple coordinate systems is not supported.
If anyone knows how to deal with exporting dual plots in a panel, do help me!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Produits

Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by