How can I print only the axes in gui to pdf?

6 ビュー (過去 30 日間)
Yumu Noma
Yumu Noma 2018 年 12 月 5 日
コメント済み: Kevin Chng 2018 年 12 月 10 日
Hi, I made a GUI using GUIDE.
The figure has an axes and I want to print it only to pdf. How can I do it?
When I print it, whole figure is printed which means the pdf includes other buttons and edit texts and so on.

回答 (1 件)

Kevin Chng
Kevin Chng 2018 年 12 月 6 日
編集済み: Kevin Chng 2018 年 12 月 6 日
Hi,
Refer to this link, so far the best solution i have tried is the solution recommended by Joost.
I extracted his solution from there and paste here :
% Create a temporary figure with axes.
fig = figure;
fig.Visible = 'off';
figAxes = axes(fig);
% Copy all UIAxes children, take over axes limits and aspect ratio.
allChildren = app.UIAxes.XAxis.Parent.Children;
copyobj(allChildren, figAxes)
figAxes.XLim = app.UIAxes.XLim;
figAxes.YLim = app.UIAxes.YLim;
figAxes.ZLim = app.UIAxes.ZLim;
figAxes.DataAspectRatio = app.UIAxes.DataAspectRatio;
% Save as png and fig files.
saveas(fig, fileName, 'png');
savefig(fig, fileName);
% Delete the temporary figure.
delete(fig);
Since copyobj function is not supported in app designer, the workaround solution here is to create a hidden figure and an axes in the figure. Then copy the information from the axes of app designer to the axes in the figure. Save it as pdf, then delete.. if you have any difficulties in following his solution, let me know.
Let say you want to visualize the save file at the end, you may add
winopen('filename')
  2 件のコメント
Yumu Noma
Yumu Noma 2018 年 12 月 10 日
Thanks for the answer but I am using GUIDE so I guess it doesn't work.
Do you know how to do it?
Kevin Chng
Kevin Chng 2018 年 12 月 10 日
try export_fig in the link above. Let me know if you have difficulties, then i try to help.

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by