Saving figure in app designer.

11 ビュー (過去 30 日間)
Happy PhD
Happy PhD 2020 年 5 月 5 日
コメント済み: Happy PhD 2020 年 5 月 6 日
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);

採用された回答

Joost
Joost 2020 年 5 月 5 日
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 件のコメント
Happy PhD
Happy PhD 2020 年 5 月 6 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by