質問

私は、軸事前配置のセットでMATLABのGUIを持っています。私は、軸の右側にそれを置くために伝説の場所のプロパティを使用しています。ただし、これを行うことにより、軸は軸が+伝説の軸の元の幅を取るようにすることを再スケーリングし得ます。サイズ直しを回避する方法はありますか?

例:

x=0:.1:10;
y=sin(x);
figure
pos=get(gca,'position');
pos(3)=.5; %#re-size axes to leave room for legend
set(gca,'position',pos)
plot(x,y)

これまでのところ私のgetます:

altテキスト

場所伝説ます:

legend('sin(x)','location','eastoutside')

... aaaaand ...

altテキスト

MATLABは、すべての元の軸の空間にそれをsquishes。これを回避任意の方法?

役に立ちましたか?

解決

編集

%# create three axes with custom position
x=0:.1:10;
y=sin(x);
hAx1 = axes('Position',[0.05 0.05 0.7 0.2]); plot(hAx1, x,y)
hAx2 = axes('Position',[0.05 0.4 0.7 0.2]); plot(hAx2, x,y)
hAx3 = axes('Position',[0.05 0.75 0.7 0.2]); plot(hAx3, x,y)

%# add legend to middle one
h = legend(hAx2, 'sin(x)'); pos = get(h,'position');
set(h, 'position',[0.8 0.5 pos(3:4)])

altテキスト

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top