Matlab: Figures without borders and toolbars
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.
Thanks, mathworks is not very helpful with removing this. I searched everywhere for “margin”, figure border, etc… I agree that it serves no purpose and it ugly. I will include this line in all of my new matlab function along with “format compact”;