Effacer les filtres
Effacer les filtres

Saving figure in app designer.

10 vues (au cours des 30 derniers jours)
Happy PhD
Happy PhD le 5 Mai 2020
Commenté : Happy PhD le 6 Mai 2020
Hi, I want to save a figure in app designer called app.ScanDataPlot.
The code below saves the figure (but just the data, with x and y axes but with no titles). I also want to include the legend of the graph (for the different curves) and include the x and y axes titles. How can I do this?
The code does not save the figure as .png, just as .fig. Any ideas how to get the figure in .png format also?
% Create a temporary figure with axes.
figScan = figure;
figAxes = axes(figScan);
% Copy all UIAxes children, take over axes limits and aspect ratio.
allChildren = app.ScanDataPlot.XAxis.Parent.Children;
copyobj(allChildren, figAxes)
figAxes.XLim = app.ScanDataPlot.XLim;
figAxes.YLim = app.ScanDataPlot.YLim;
figAxes.ZLim = app.ScanDataPlot.ZLim;
figAxes.DataAspectRatio = app.ScanDataPlot.DataAspectRatio;
% Save as png and fig files.
fileName = fullfile([pathway,'\data','\fig-file\'], 'WorstLocation.fig');
saveas(figScan, fileName, 'png');
savefig(figScan, fileName);

Réponse acceptée

Joost
Joost le 5 Mai 2020
You might want to take a look at this contribution:
Regarding the saving as png: I guess that it does not work because fileName already has the fig extension.
Could you give this a try:
fileName = fullfile([pathway,'\data','\fig-file\'], 'WorstLocation');
saveas(figScan, [fileName '.png'], 'png');
savefig(figScan, [fileName '.fig']);
  1 commentaire
Happy PhD
Happy PhD le 6 Mai 2020
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by