EPS figures from MATLAB - bounding box problems?

8,970 views
Skip to first unread message

happyhessian

unread,
Jul 17, 2009, 8:35:30 AM7/17/09
to LaTeX Users Group
Hi guys,

I'm going crazy here trying to figure out what appears to be a
bounding box problem. I'm using MATLAB to generate EPS files (via
save as... => file type=EPS) and for some reason my figures keep
getting cut off on the left side. I tried epstool --copy -b input.eps
output.eps and it didn't help. I tried re-saving it--I don't remember
having this problem before so I'm really confused.

Anyone know what I should be doing differently? I can attach stuff if
you want. (Obviously, I'm scaling the figure to \textwidth). It's
just so frustrating when you can't figure out what the problem is!

Best,

md

C Hanck

unread,
Jul 18, 2009, 3:18:31 AM7/18/09
to LaTeX Users Group
Hi,

my advice would be to convert the eps file to a pdf using epstopdf and
then use includegraphics where you can then specify the size of the
picture.

Best,

Christoph

drorata

unread,
Jul 18, 2009, 4:44:48 AM7/18/09
to LaTeX Users Group
You can try and edit the bounding box of the EPS directly.

mmdanziger

unread,
Jul 19, 2009, 4:03:56 AM7/19/09
to LaTeX Users Group
Well, I got it to work with pdflatex after converting with epstopdf.
It's still irksome, though, that it didn't work with the regular EPS
in LaTeX. I wish I understood it a little better. Maybe when I'm not
on such a tight schedule I'll figure out how all this ghostscript
stuff works once and for all!

Thanks for the advice,

md

DIN1587

unread,
Jul 20, 2009, 2:20:33 AM7/20/09
to LaTeX Users Group
Hi happyhessian,

in the \includegraphics command, try specifying the bounding box:

\begin{figure}[H]
\centering
\includegraphics[width=0.4\textwidth, bb= 166 162 500 355, clip=true]
{../my_matlab_figure.eps}
\end{figure}

I never had problems with eps-figures from Matlab. I looked at them
with GhostView and determined the bounding box I'd like. It's another
step in between but you don't have to convert your files. I never
tried without specifying the bounding box. If you find a way to get
that to work, let me know.

~DIN1587

Peter Flynn

unread,
Jul 20, 2009, 6:23:43 PM7/20/09
to latexus...@googlegroups.com
On Sun, Jul 19, 2009 at 9:03 AM, mmdanziger <mmdan...@gmail.com> wrote:

Well, I got it to work with pdflatex after converting with epstopdf.
It's still irksome, though, that it didn't work with the regular EPS
in LaTeX.
 
Matlab's EPS is notoriously broken. Has been for years and years.

///Peter

DIN1587

unread,
Jul 23, 2009, 5:06:35 AM7/23/09
to LaTeX Users Group
Hi!

I just found something on Matlab and Bounding Boxes here:
http://www.mathworks.com/company/newsletters/digest/december00/export.html
I'd appreciate a note when you tried it to know whether it works or
not ... I'm currently not using Matlab.
~DIN1587

Mavaron Liang

unread,
Aug 15, 2009, 12:26:17 AM8/15/09
to LaTeX Users Group
I had the same problem before.... A simple solution is to open your
figure in the figure window, and then type in the following lines in
the command line:

print -epsc -loose yourfilename.eps

It worked for me.. Hope it can solve your problem as well.

Matt

unread,
Aug 30, 2012, 1:50:30 PM8/30/12
to latexus...@googlegroups.com
Correction:
print -deps yourfilename.eps
with a "d" in -deps

(not sure how I can edit my previous post)

On Thursday, August 30, 2012 12:33:22 PM UTC-5, Matt wrote:
update:   MATLAB R2011a command
print -eps yourfilename.eps
without the loose option provides a tight bounding box that does not crop figure. 

toto

unread,
Sep 7, 2012, 9:33:19 AM9/7/12
to latexus...@googlegroups.com


Le vendredi 17 juillet 2009 14:35:30 UTC+2, happyhessian a écrit :
Hi guys,
Hello,
I'm going crazy here trying to figure out what appears to be a
bounding box problem.  I'm using MATLAB to generate EPS files (via
save as... => file type=EPS) and for some reason my figures keep
getting cut off on the left side.  I tried epstool --copy -b input.eps
output.eps and it didn't help.  I tried re-saving it--I don't remember
having this problem before so I'm really confused.
May I suggest you to use a much better way to create eps file with matlab using the following code http://www.mathworks.com/matlabcentral/fileexchange/23629 ?

You can also use  the following command to modify you eps (you can have to ajust the 4 numbers by hand) : epsffit 0 53 362 219 OldFigure.eps NewfFigure.eps

Sometime a combination of the two is needed. I am using it a lot to build movies using beamer and animate.

Hope this help, sincerely yours,

muneer332

unread,
Oct 30, 2013, 10:41:02 AM10/30/13
to latexus...@googlegroups.com
Just run or se quik build as  latex, dvi to ps, ps to pdf and view pdf

Alain Batailly

unread,
Oct 30, 2013, 12:50:47 PM10/30/13
to latexus...@googlegroups.com
Hi,

Have you tried the eps2eps command ? That may remove some of Matlab clipping masks for instance...

If it still does not work, could you upload an eps and your code ?

Alain


2013/10/30 muneer332 <munee...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to latexusersgro...@googlegroups.com.
To post to this group, send email to latexus...@googlegroups.com.
Visit this group at http://groups.google.com/group/latexusersgroup.
For more options, visit https://groups.google.com/groups/opt_out.

Gonzalo Fernández de Córdoba Martos

unread,
Jan 21, 2014, 4:42:50 PM1/21/14
to latexus...@googlegroups.com
Ey Toto,
your epsffit command worked perfectly well for me.
Thanks so much. I was going crazy with that left crop.
Yours, Gonzalo
Reply all
Reply to author
Forward
0 new messages