matlab边算边出图命令,Matlab:不包含边界和工具栏的figure(移除保存图片的白边)...

当我们使用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.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值