Matlab does not save the entire figure

4 次查看(过去 30 天)
I cannot get matlab to save my entire figure. There is something wrong with my papersize definitions, but I cannot control them using axes. How can I print the entire figure?
if true
%%PLOTS
fig=figure;
plot(x(200:1600),data(200:1600,[94 104 114 138 199 214 266]),'linewidth',2);axis tight;
legend('A', 'B', 'C', 'D', 'E', 'F', 'G');legend boxoff;
set(gca, 'box', 'off','YTick', [],'ycolor',[1,1,1]); % remove y axis ticks and make axis white.
set(gca,'FontSize',16,'LineWidth',2,'fontweight','bold','TickDir','out','units','centimeters','position',[2,2,20,18]);
xlabel('Strength','fontweight','bold','fontsize',16);
ylabel('a.u.','fontweight','bold','fontsize',16,'color','k');
% create another x-axis for top-x-axis
axes('xlim', [x(200) x(1600)],'color', 'none','XAxisLocation','top');set(gca,'FontSize',16,'LineWidth',2,'fontweight','bold','TickDir','out','units','centimeters','position',[2,2,20,18],'YTick',[],'ycolor',[1,1,1]);
xticks([241.138 259.687 281.328 306.903 337.594 375.104]);,
xticklabels({'2.8','2.6','2.4','2.2','2.0','1.8'});
xlabel('{\itg}-value','fontweight','bold','fontsize',16);
% create another x-axis for top-x-axis for minor ticks
axes('xlim', [b_mT(200) b_mT(1600)],'color', 'none','XAxisLocation','top');set(gca,'FontSize',16,'LineWidth',1.5,'fontweight','bold','TickDir','out','units','centimeters','position',[2,2,20,18],'YTick',[],'ycolor',[1,1,1]);
xticks([250.069 270.075 293.560 321.518 355.362]);,
xticklabels({'','','','',''});
% Making the insert plot:
axes('units','centimeters','Position',[3 3.5 12 10])
plot(x(400:1000),data(400:1000,[94 104 114 138 199 214 266]),'linewidth',2);axis tight;
set(gca, 'box','off','YTick', []); set(gca,'ycolor',[1,1,1]); % remove y axis ticks and make axis white.
set(gca,'FontSize',16,'LineWidth',2,'fontweight','bold','TickDir','out');
% create another x-axis for top-x-axis
axes('xlim', [x(400) x(1000)],'color', 'none','XAxisLocation','top');set(gca,'FontSize',16,'LineWidth',2,'fontweight','bold','TickDir','out','units','centimeters','position',[3 3.5 12 10],'YTick',[],'ycolor',[1,1,1]);
xticks([259.687 270.075 281.328 293.560 306.903 321.518]);,
xticklabels({'2.6','2.5','2.4','2.3','2.2','1.1'});
xlabel('{\itg}-value','fontweight','bold','fontsize',16);
% create another x-axis for top-x-axis for minor ticks
axes('xlim', [x(400) x(1000)],'color', 'none','XAxisLocation','top');set(gca,'FontSize',16,'LineWidth',1.5,'fontweight','bold','TickDir','out','units','centimeters','position',[3 3.5 12 10],'YTick',[],'ycolor',[1,1,1]);
xticks([264.779 275.587 287.314 300.083 314.041]);,
xticklabels({'','','','',''});
% print figure
print(fig,'-fillpage','-dpng','C:\Users\s072204\Google Drive\Phd Thesis\Figures\fig.png');
  1 个评论
Don Zheng
Don Zheng 2017-7-19
Can you provide the data used in this example code and explain what you mean by "entire figure"?

请先登录,再进行评论。

回答(1 个)

Chad Greene
Chad Greene 2017-7-19
I recommend using export_fig instead of print. It's easier to use, faster, the image quality is often better, and sizing/cropping are never issues.

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by