How to get rid of white box in figure exported from Matlab to eps format?

17 views (last 30 days)
Each time I export my plots into eps format using hgexport function I get three white boxes in the eps figure, that seem to provide the background, but also they distort the size of the imported figure and I have to delete them every time I import them into my graphical editor. Is there a way to turn of the creation of these boxes? Perhaps someone could suggest what eps primitives correspond to these boxes, then I could write a function to delete them from the eps file.

Answers (4)

Matt Fig
Matt Fig on 20 Apr 2011
I recommend you abandon the built-in MATLAB export function and go for this award-winning FEX submission: export_fig

Jan
Jan on 8 Jun 2011
I agree with Matt: HGEXPORT is simply not the most user-friendly method.
Another method:
set(FigHandle, 'Units', 'normalized', 'PaperPositionMode', 'auto');
print(FigHandle, '-depsc2', '-r300', '-tiff', '-loose', 'File.eps');

Charlie
Charlie on 12 Sep 2011
I have a similar problem. I wish to make a 3D surface plot using the mesh function. I then kill the grid, box, and axis (e.g. axis off, etc.), and then wish to make the background transparent so type:
set(gca, 'color', 'none')
This above set command does indeed kill the background default white color and makes the background transparent (or seemingly so) until I save the figure as an .eps file and open it in Adobe Illustrator, where there is still this pesky white background! Also, I notice, whenever I save a file after selecting 'none' for the color, the white background momentarily appears and then immediately goes away just after saving, almost like a camera flash. Is there some nutty default save feature in MATLAB that automatically saves a figure with a white background despite the previous changes you've made?
If anyone is familiar with this problem, I would be most appreciative. I have used the export_fig function but it saves the figure just as it appears on the screen, with the off-whitish-gray background. I really need a transparent figure to open in Adobe Illustrator, where there is no colored background whatsoever, only the figure.
Much oblige to anyone knowledgeable in how to resolve this annoying problem.
Best, Charlie

Flavv
Flavv on 23 Mar 2019
I have similar issues 8 years after your first post. I don't really understand why they add this background in the first place. At least there should exist an option to remove it. My solution so far is to open each exported image with Inkscape and manually remove these extra layers.

Products

Community Treasure Hunt

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

Start Hunting!