保存为eps后,MATLAB图在其框外

问题描述 投票:0回答:1

我绘制了下图,并将其保存为eps。

fig1

当我将其转换为PDF时,我得到以下内容:

fig2

尽管我使用了ylim命令,但是蓝色图已经超出了界限。下面请看我的代码:

    h=figure(2);
set(0,'defaultAxesFontName', 'times',...
    'defaultTextFontName','times',...
    'DefaultAxesFontSize', 8, ...
    'DefaultTextFontSize', 8, ...
    'DefaultLineLineWidth',.5,...
    'DefaultLineMarkerSize', 3,...
    'DefaultTextInterpreter','latex')
h.Color='w';
h.Units = 'inches';
h.Position=[1 .5 3.61 2.71];
h.PaperPosition=[1 .5 3.61 2.71];

subplot(2,1,1)
plot(T,1000*yt,'r')
ylabel('$$y$$~(mV)','interpreter','latex')
xlim([0 49.5])
ylim([-75 75])
hold on
line([5 5],[-75 75],'linestyle','--','color','k','linewidth',1)
set(gca,'Xtick',5:10:50,'XTickLabel',5:10:50)  
set(gca,'xticklabel',[])
ylabh = get(gca,'YLabel');
 set(ylabh,'Position',get(ylabh,'Position') -[1.2 0 0])
set(gca,'xticklabel',[])

subplot(2,1,2)
plot(T,1000*ut)
ylabel('$$u$$~(mV)','interpreter','latex')
xlabel('$$t$$~(s)','interpreter','latex')
xlim([0 49.5])
ylim([-600 600])
hold on
line([5 5],[-600 600],'linestyle','--','color','k','linewidth',1)
set(gca,'Xtick',5:10:50,'XTickLabel',5:10:50)  
hold on
line([0 T(end)],[447 447],'color','k','linestyle',':','linewidth',1)
line([0 T(end)],[-447 -447],'color','k','linestyle',':','linewidth',1)
print -depsc fig_siso_bad_sat.eps
matlab plot
1个回答
0
投票

除非你摆弄出口属性,否则内置的导出函数通常会重新缩放图形元素。尝试使用这个库https://au.mathworks.com/matlabcentral/fileexchange/23629-export-fig

© www.soinside.com 2019 - 2024. All rights reserved.