matlab画图标注清空,matlab画图,如何消除图形中多余的空白区域

matlab图形的gca中,主要由position、outerPostion、以及tightInset来决定坐标轴,图形,标注等的位置。举例如下:

N = 100;

x = 1:N;

y = rand(1,N);

set(gcf, 'PaperSize', [5 3], 'PaperPosition', [0 0 5 3]);

delete(gca); clf; % Clean up the figure

plot(x, y);

h=zeros(1,3);

h(1) = annotation('rectangle', get(gca, 'Position'), 'Color', 'Magenta');

h(2) = annotation('rectangle', get(gca, 'OuterPosition'), 'Color', 'Yellow');

h(3) = annotation('rectangle', get(gca, 'Position') + ...

get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1], ...

'Color', 'Red');

set(h,'LineWidth', 3);

201183619_1_20200903101415802.jpg

可以看到很大部分的空白,如何方便快速的消除这些空白呢?两种方法:

1、输入:

set(gca, 'Position', get(gca, 'OuterPosition') - ...

get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);

效果如下:

delete(gca); clf;

plot(x, y);

set(gca, 'Position', get(gca, 'OuterPosition') - ...

get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);

h = zeros(1,2);

h(1) = annotation('rectangle', get(gca, 'Position'), 'Color', 'Magenta');

%annotation('rectangle', get(gca, 'OuterPosition'), 'Color', 'Yellow');

h(2) = annotation('rectangle', get(gca, 'Position') + ...

get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1], ...

'Color', 'Red');

set(h,'LineWidth', 3);

201183619_2_20200903101415974.jpg

2.、输入matlab一个未公布的命令:

set(gca,'LooseInset',get(gca,'TightInset'))

也可以达到同样的效果。

另外,有谁能告诉bode(tf(1,[1 1]))之后,再把图片缩小后,下面的x轴标准会被挡住,该如何解决?

201183619_3_20200903101416162.jpg

我试了很多方法,,貌似都不行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值