gpt4 book ai didi

Matlab ylabel截止使用plotyy函数

转载 作者:太空宇宙 更新时间:2023-11-03 19:34:48 26 4
gpt4 key购买 nike

如随附的屏幕截图所示,matlab 的 EPS 输出正在切割右侧 Y 轴上的标签。

我正在使用 plotyy 函数,并通过以下方式打印到 eps:print(f1,'-depsc2' ,'figure1.eps');

我已经尝试更改 paperposition 属性以及 papersize 属性,并且这些属性似乎在每次调整时都与另一个属性一起缩放,因此我永远无法让右侧的纸张尺寸增加。

我已将 paperpositionmode 设置为手动。

有没有人有什么想法?

我已经创建了一些自给自足的示例代码并重现了该问题。增加刻度和字体大小时会产生问题。然而,这对我的情况来说是必不可少的。

close all;

% example data:
x = 0:0.01:4;
y1 = 5*sin(2*pi*x+0.1) + 20;
y2 = 0.09*sin(2*pi*x);

tickfontsize = 18;
labelfontsize = 20;

% begin figure:
f1 = figure(1);
[ax, h1, h2 ] = plotyy(x,y1,x,y2)

% axis labels and font size:
set(get(ax(2),'Ylabel'),'String','Test1') ;
set(get(ax(1),'Ylabel'),'String','test2') ;
set(get(ax(1),'Ylabel'),'FontSize',labelfontsize) ;
set(get(ax(2),'Ylabel'),'FontSize',labelfontsize) ;

% left hand side ticks:
set(ax(1),'YLim',[6 10]);
set(ax(1),'YTick',[6:1:10]);
set(ax(1),'FontSize',tickfontsize);

% right hand side ticks:
set(ax(2),'YLim',[-0.13 0.14]);
set(ax(2),'YTick',[-0.1:0.05:0.1]);
set(ax(2),'FontSize',tickfontsize);

%print figure to eps:
print(f1,'-depsc2', './simpleoutput.eps');

Screenshot of EPS output

最佳答案

改变轴的位置使它们变窄:

set(ax(1),'Position', [0.13 0.11 0.775-.08 0.815]);
set(ax(2),'Position', [0.13 0.11 0.775-.08 0.815]);
% Original position was [0.13 0.11 0.775 0.815]
% Applied change in width: "-.08". Choose as desired

如果你需要保持轴的比例,你也应该修改高度(第四个数字)。

关于Matlab ylabel截止使用plotyy函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18984154/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com