我正在將matlab圖保存爲png。我想設置打印尺寸緊屏幕尺寸,所以我用:Matlab figure as PNG
set(gca(),'LooseInset',get(gca(),'TightInset')); %set print size tight to the screen size
但是我的形象不被保存緊屏幕尺寸,也不在屏幕的中心......
這裏是我的一切,代碼我已經嘗試過:
function []=FilledCircle1(x0,y0,Radius,N,col1)
if(N<=1)
error('N must be greater than 1');
end
hold on
axis equal
% axis off
hold on
t=(0:N)*2*pi/N; %t=-pi:0.01:pi
x=Radius*cos(t)+x0;
y=Radius*sin(t)+y0;
c1=fill(x,y,col1);
set (c1, 'edgecolor','k')
set(gcf,'PaperUnits','inches','PaperSize',[0.8666,0.8666],'PaperPosition',[0 0 0.8666 0.8666])%setting size (130/150, 130/150, 150pixels per inch being the default size of img), paper position is imporrtant as otherwise i will have extra border
% % set(gcf,'Position', [0 0 4.4466 3.5733], 'units','inches')
% % iptsetpref('ImshowBorder','tight');
set(gca(),'LooseInset',get(gca(),'TightInset')); %set print size tight to the screen size
% set(gcf, 'Position', get(0,'screensize'));
set(gcf,'color','none'); %set backgroound color to transparent
fig = gcf;
fig.InvertHardcopy = 'off'; %saves the fig with the set background color
我想我的PNG文件看起來像這樣:
但是它看起來是這樣的:
有人可以幫助我瞭解我究竟做錯了什麼? 謝謝!
第一張圖片與第二張圖片的關係並不完全清楚。無論如何,insets適用於*軸*,而不是繪製在其中。如果要繪製的對象居中放大,則必須在保存之前更改軸限制。 – excaza
第一張圖片只是爲了表明我想要繪製的實心圓被居中並填滿整個屏幕。 @excaza – Mraquel