LaTeX document and BoundingBox eps file created by matplotlib

I am having a problem with including the eps file generated by matplotlib in a LaTeX document. The size of the figure does not seem to be recognized correctly, and the signature is superimposed on the figure.

See image below. This is an image of a latex document that includes drawings created by matplotlib. The LaTeX source file and the python source code for plotting are shown below.

==========================

Image of the LaTeX document.

=========================

Figure 1. Overlays with an inscription. LaTeX seems to recognize a smaller digit than the actual size.

2. eps, 1., bb includegraphics LaTeX. BoundingBox eps %%BoundingBox: 18 180 594 612, bb bb=0 0 594 612. , . , 2 . , -, .

, , . , matplotlib LaTex, , .

matplotlib - 1.1.1rc, - Ubuntu 12.04. LaTeX latex, dvipdfm.

>>> import matplotlib
>>> matplotlib.__version__
'1.1.1rc'

$ latex --version
pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013)
kpathsea version 6.1.1
Copyright 2013 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.5.16; using libpng 1.5.16
Compiled with zlib 1.2.7; using zlib 1.2.7
Compiled with xpdf version 3.03


$ dvipdfm --version

This is dvipdfmx-20130405 by the DVIPDFMx project team,
modified for TeX Live,
an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.

Copyright (C) 2002-2013 by the DVIPDFMx project team

This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

LaTeX.

\documentclass{article} 
\usepackage[dvips]{graphicx,color}
%\usepackage{amsmath,amssymb}

%\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}



\begin{document}

This is the first paragraph of the text.
Today is a good day. 

\begin{figure}[ht]
\begin{center}
\includegraphics[width=.5\linewidth]{fig.eps}
\caption{This is the caption of the figure included without specifying bb parameters.}
\label{fig1}
\end{center}
\end{figure}

This is the second paragraph of the text written below the first figure environment.
Tomorrow will be a bad day.

\begin{figure}[hb]
\begin{center}
\includegraphics[bb=0 0 594 612, width=.5\linewidth]{fig.eps}
\caption{This is the caption of the figure included with the first two bb parameters set zero.}
\label{fig2}
\end{center}
\end{figure}

% Note that fig.eps has the following bounding box information.
% $ grep BoundingBox fig.eps 
% %%BoundingBox: 18 180 594 612


\end{document}

python, .

#!/usr/bin/python

import matplotlib.pyplot as plt

plt.plot([0, 1, 2], [0, 2, 4], '-b')
plt.savefig('fig.eps')
+3
3

, dvips. ps2pdf. , , dvipdfm - .

+1

plt.figure() figsize=(x,y). plt.savefig() bbox_inches='tight', .

, , "PS", :

import matplotlib as mpl
mpl.use('PS') 

, format='eps' savefig, , eps , .

+4

OSX, :

$ gs -o temp.ps -sDEVICE = ps2write -dEPSCrop matplotlib.eps

$ ps2eps temp.ps

Links related to this topic: http://syatsin.blogspot.jp/2016/09/how-to-solve-bounding-box-problem-with.html

0
source

All Articles