Saving figure in app designer.
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Happy PhD
el 5 de Mayo de 2020
Comentada: Happy PhD
el 6 de Mayo de 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);
0 comentarios
Respuesta aceptada
Joost
el 5 de Mayo de 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']);
Más respuestas (0)
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!