Saving multiple figures together to a PDF
25 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to print/export my multiple output figures to PDF. The figure contains a surface plot and an uitable. I thought exportgraphics function will do my work but it seems like it does not support UI components. The desired output is to have a PDF with all the figures on a new page as similar to how they are displayed in figure window.
x = (rand(36,1))/10;
box = struct('B1',x(1:9),'B2',x(10:18),'B3',x(19:27),'B4',x(28:36));
box = structfun(@(fld) reshape(fld,3,3),box,'UniformOutput',false);
box = struct2cell(box)';
rows = [50,100,150]; %Axis data
col = [1000,3000,5000]; %Axis data
rnames = {'50','100','150'}; % These are column names
cnames = {'1000', '3000', '5000'}; % These are row names
sz = size(box);
for idx = 1:sz(1,2)
list = box{idx};
fig = figure('Position',[100 100 600 550]);
axes('Parent',fig,'position',[.1,.4,.8,.55],'Visible','off');
surf(col,rows,list);
xlabel('xAxis');
ylabel('yAxis');
zlabel('zAxis');
t = uitable('Parent',fig,'Data',list,'ColumnName',cnames,...
'RowName',rnames,'Units','Normalized','position',[0.075,0.025,0.75,0.3]);
exportgraphics(fig,'output.pdf','Append',true);
end
Any ideas on how it can be done? I tried using export_fig but it needs Ghostscript installed and I cannot install any third party software.
Thanks for the help,
0 个评论
回答(1 个)
Adam Danz
2022-7-14
编辑:Adam Danz
2022-7-14
Thanks for providing the code! The question title makes it seems like you're plotting multiple figures but your code shows that you produce one figure with multiple components.
fig = uifigure('Position',[100 100 600 550]);
ax = axes(fig,'position',[.1,.4,.8,.55],'Visible','off');
surf(ax,col,rows,list);
xlabel(ax,'xAxis');
ylabel(ax,'yAxis');
zlabel(ax,'zAxis');
t = uitable(fig,'Data',list,'ColumnName',cnames,...
'RowName',rnames,'Units','Normalized','position',[0.075,0.025,0.75,0.3]);
exportapp(fig,'output.pdf');
end
*not tested
However, exportapp does not have an append option. You could create a pdf with exportapp and then append the pdf with exportgraphics as long as the content supplied to exportgraphics does not contain uicomponents.
2 个评论
Adam Danz
2022-7-14
I see, that makes sense. getframe might be useful too but I don't have time at the moment to map that out.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!