我想将此图片导出为 pdf 格式:
P2_波浪号 =
0.1029 0.4118 0.0245 0.1814 0.2794
0.3925 0.0234 0.0280 0.4626 0.0935
0.0928 0.1237 0.2680 0.2990 0.2165
0.0699 0.2219 0.0182 0.5106 0.1793
0.2611 0.0887 0.0837 0.3251 0.2414
figure('color',[1,1,1])
hBar2=bar3(P2_tilde);
colormap('pink')
set(hBar2,{'CData'},C);
set(gca,'xticklabel',surfaces)
set(gca,'yticklabel',surfaces)
surfaces={'Equipment','Patient','Hygiene products','Near-bed','Far-bed'};
colorbar
zlabel('Probability');
colormap('pink')
colorbar('location','southOutside')
set(gca,'xticklabel',surfaces)
set(gca,'yticklabel',surfaces)
surfaces={'Equipment','Patient','Hygiene products','Near-bed','Far-bed'};
zlabel('Probability');
要导出为 PDF 格式:
currentScreenUnits=get(gcf,'Units') % Get current screen units
currentPaperUnits=get(gcf,'PaperUnits') % Get current paper units
set(gcf,'Units',currentPaperUnits) % Set screen units to paper units
plotPosition=get(gcf,'Position') % Get the figure position and size
set(gcf,'PaperSize',plotPosition(3:4)) % Set the paper size to the figure size
set(gcf,'Units',currentScreenUnits) % Restore the screen units
print -dpdf ptilde % PDF called "ptilde.pdf"
完全脱离页面。任何想法如何将图形在画布上居中并使其只有图形的大小?不然怎么修剪?