File Exchange

image thumbnail

Fix bounding box in MATLAB exported encapsulated postscript (.eps) files

version 1.0.0.0 (1.89 KB) by Nathan Tomlin
Tweak bounding box (excess space) from matlab exported encapsulated postscript files (.eps)

1 Download

Updated 11 Feb 2008

View License

I found that the bounding box on matlab exported eps files was too large on the left and right side. This script just reads in the .eps file and reduces the bbox.

% matlab seems to compute a bounding box on eps files which is too
% large in the x-direction
%
% this script fixes the bounding box.
% it is 99% stolen from fixeps.m, located here:
% http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4818&objectType=file
% the only change is that this actually changes the bbox numbers
% seriously, the only change is the addition of lines 19,20,31,32
%
% boundingbox has form of:
% %%BoundingBox: x1 y1 x2 y2
% where (x1,y1) is lower-left and (x2,y2) is upper-right
%
% matlab computes x1 too small and x2 too large

Cite As

Nathan Tomlin (2021). Fix bounding box in MATLAB exported encapsulated postscript (.eps) files (https://www.mathworks.com/matlabcentral/fileexchange/18681-fix-bounding-box-in-matlab-exported-encapsulated-postscript-eps-files), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Vedrana Dahl

Works ok for some figures, but there is a problem if the second occurrence of Box requires less trailing space. Also can't handle situation if the new line is longer than the old. With slight improvements provides a good solution for fixing eps bounding box.

Mark Tschopp

This script works fine. I immediately modified the function inputs to allow the user to enter the bounding box movements (instead of hard coding it into the function).

It would be nice if the function automatically detected white space and minimized the bounding box accordingly, though.

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Acknowledgements

Inspired by: Remove Space in MATLAB Exported Postscript File

Community Treasure Hunt

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

Start Hunting!