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);

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

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);

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

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

也可以达到同样的效果。

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


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



广告阶段:
本人开了淘宝店,欢迎你惠顾,价格优惠,购买是说明来于csdn,将给你最实惠价格。

店名:小时代乐园

承诺:本店以诚信求生存,以质量求人员,货真价实,绝无欺骗行为。
简介:本店主要营销大品牌、安全有保障的商品,提供儿童益智娱乐品牌宝贝,让你全方位精心打扮,提升体验度和品味,让你买得开心,用得放心,穿得舒心,听得暖心。



  • 4
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值