matlab画图,如何消除图形中多余的空白区域
2014-06-17 10:46
369 查看
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轴标准会被挡住,该如何解决?
我试了很多方法,,貌似都不行。
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轴标准会被挡住,该如何解决?
我试了很多方法,,貌似都不行。
相关文章推荐
- Matlab画图技巧之消除空白(二)
- Matlab画图技巧之消除空白
- 【Matlab画图】如何向Matlab图形中添加Latex数学标示
- Visio 画图去掉页边距(图形四周的空白区域)的解决办法
- Matlab画图如何去掉图形框右边和上边的刻度
- MATLAB如何保存显示的图片不留空白区域
- 【Matlab画图】如何去除Matlab图形中的边界
- 【Matlab画图】如何去除Matlab图形中的边界2
- 如何消除网页顶部的一行空白?
- 如何消除sharepoint升级到2010后主页上多余的"Home"内容
- MATLAB画图入门篇--各种基本图形绘制的函数与实例
- 如何在MATLAB图形窗口中复制数据文件。
- 利用matlab如何在图形中绘制箭头
- 如何消除matlAB启动时的Warning:Name is nonexistent or not a directory ...
- DIV+CSS排版时 如何解决img图片元素下多余空白
- 如何消除网页顶部的一行空白?
- Matlab如何判断一个点是否落在一个不规则的封闭区域中
- matlab 如何画图时将数据点的值在图中显示出来
- vs2008中如何在项目属性中切换“图形形式”和“控制台形式”——即调出或消除黑窗口
- Matlab 学习 画图篇 一 二维图形