Saving images from figure window in Matlab.

2 views (last 30 days)
I'm saving images 500 dpi, using rendering in export setup from figure window in Matlab. But there is little change I have to make. I get image like below: I mean there is lot of white space at sides which I want to eliminate. White portion is marked with black sketch in image.
I want to make my image look like this: Whitout any white portion at sides.
How to do this?
Thanks.

Accepted Answer

Chad Greene
Chad Greene on 27 Jul 2017
I recommend using export_fig, which crops the white space by default. The syntax is simply
export_fig myfig.png -r500
if you want 500 dpi. If you want a tiny bit of white space around the image, say, 1% of the figure width, do
export_fig myfig.png -r500 -p0.01
  2 Comments
Naseeb Gill
Naseeb Gill on 27 Jul 2017
Edited: Naseeb Gill on 27 Jul 2017
Thanks @Chad Greene for reply but when I proceed as you suggest I get following error:
Undefined function 'export_fig' for input arguments of type 'char'.
Error in boxplot_graph_draw (line 84)
export_fig myfig.png -r500 -p0.01 ;
The code I'm running is
// values of Rc, Gc etc. I loaded from laptop in workspace in form of //array
X = [Rc;Gc;Bc;Rs;Gs;Bs;Rl;Gl;Bl];
G = [zeros(length(Rc), 1); ones(length(Gc), 1); 2*ones(length(Bc), 1);3*ones(length(Rs), 1);...
4*ones(length(Gs), 1);5*ones(length(Bs), 1);6*ones(length(Rl), 1);7*ones(length(Gl), 1);...
8*ones(length(Bl), 1)];
boxplot(X,G,'Labels',{'Yc','Cbc','Crc','Ys','Cbs','Crs','Yl','Cbl','Crl'});
export_fig myfig.png -r500 -p0.01 ;
I added export_fig folder to maltlab path also.
Naseeb Gill
Naseeb Gill on 28 Jul 2017
Thanks @Chad Greene It works fine. Actually I made mistake in path addition. What I did was, I just select altmany-export_fig-5be2ca4 folder and click on save. But what I need to do is, I should open this folder using pathtool and then click on save.

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!