Matlab:不包含边界和工具栏的figure(移除保存图片的白边)
来源:互联网 发布:人工智能豆瓣 编辑:程序博客网 时间:2024/05/22 10:59
当我们使用matlab的imshow命令显示图片时,会有白框和工具栏出现。在保存图片时会出现白色的边框。下面将说明如何去除这些显示。
Matlab启动时运行脚本'script.m',文件位置在~/matlab/ directory(windows下在matlab安装路径的bin目录下新建script.m译者注)。在该文件加上一行,或者在显示figure时加命令
>>iptsetpref('ImshowBorder','tight');
图片即可显示,并且保存时没有白框。此方法仅仅适用'imshow'命令,不适用'imagesc'命令。
如果在'startup.m'文件中包含以下命令:
%在所有的figure去除菜单栏和工具栏
>>set(0,'DefaultFigureMenu','none');
%'disp'命令显示无空行
>>format compact;
这三条命令可以去除matlab默认的很多没有意义的显示信息。
翻译原文:http://www.shawnlankton.com/2007/06/matlab-figures-without-borders-and-toolbars/comment-page-1/#comment-2101
Something that has bothered me for *the entire* time I’ve used it is that when you show images using ‘imshow’ the resulting figure has the image surrounded in a sea of gray border. Well, I hate that gray border. It serves no purpose and today I have figured out how to remove it!
Matlab runs a script called ‘startup.m’ when it starts. This is located in your ~/matlab/ directory. If you include this line into that file (or just type it before you make the figure) then you remove the gray border:
>>iptsetpref('ImshowBorder','tight');
Its glorious… Now the picture scales to fill the whole window! (note this only works with the ‘imshow’ command, not ‘imagesc’).
BUT! That’s not all. I also learned about some other cute little tricks that should be included in your startup.m (if you’re me at least).
%removes menu and toolbar from all new figures
>>set(0,'DefaultFigureMenu','none');
%makes disp() calls show things without empty lines
>>format compact;
I feel like these three commands cut a lot of the pointless (inefficient) crap out of Matlab’s default display interface. Thanks to commenter Matt who pointed me toward the set(0,’Default… thing. You can use this to set up *tons* of settings so that you don’t have to set it every time. Just call:
>>set(0,'Default');
For some other useful tips on exporting figures for papers, check this related post.
- Matlab:不包含边界和工具栏的figure(移除保存图片的白边)
- Matlab:不包含边界和工具栏的figure(移除保存图片的白边)
- matlab保存figure中的图片去掉白边
- matlab保存figure中的图片去掉白边
- matlab保存figure中的图片去掉白边
- matlab保存figure中的图片去掉白边
- matlab保存figure中的图片去掉白边
- matlab 图片的读入和显示(imread函数和figure函数)
- 将matlab的figure保存为pdf,避免图片太大缺失
- Matlab中Figure高效保存为图片
- matlab figure的用法
- Matlab: figure的用法
- Matlab: figure的用法
- Matlab Figure 图形保存以及 Simulink 中 Scope 窗口坐标标注(label)的设置
- Matlab Figure 图形保存以及 Simulink 中 Scope 窗口坐标标注(label)的设置
- matlab的figure与java swing不兼容
- 设置matlab画出的figure图像导出图片的大小
- matlab保存figure
- java堆栈与队列
- LOADICON
- 敏捷开发实践(5)-有些工具不得不用
- 本章主要介绍C语言程序的结构和书写规则,以及Turbo C V2.0的基本操
- 编程之美2014---大神与三位小伙伴
- Matlab:不包含边界和工具栏的figure(移除保存图片的白边)
- oracle 关闭、启动
- hdu 1166 敌兵布阵 解题报告
- hdu2235 机器人的容器
- TOJ:Least Common Multiple
- 图的广度优先遍历算法
- java中static的作用
- 选择排序算法中的交换数值问题
- c++ primer阅读笔记-15章-2