1

Why the EPS figure generated by LaTeX has a black background?

The example in http://roth.cs.kuleuven.be/w-ess/index.php/Creating_LaTeX_figures_with_the_use_packages_tikz_and_pgfplots#Export_as_eps is used to generate the EPS figure.

\documentclass[a4paper]{article}

\usepackage{lipsum}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{
 compat=1.3,
 tick label style={font=\small},
 label style={font=\small},
 legend style={font=\footnotesize}
}
\usepgfplotslibrary{external}
\tikzexternalize[prefix=fig/]
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource";
dvips -o "\image".ps "\image".dvi;
ps2eps "\image.ps"}}

\title{\LaTeX\ plots with \texttt{tikz} and \texttt{pgfplots}}
\author{Roel Van Beeumen}
\date{April 17, 2012}

\begin{document}

\maketitle


% == A first plot ======================================== %
\section{A first plot}

\lipsum[1]
\begin{figure}[h]
\centering
% -------------------------------------------------------- %
\tikzsetnextfilename{first-plot}
\begin{tikzpicture}
\begin{axis}
[xlabel=$x$,ylabel=$\sqrt{|x|}$,
 axis x line=bottom,axis y line=left,
 ymax=2.1,xmax=4.4]
\addplot[blue,mark=none,domain=-4:4,samples=201]
 {sqrt(abs(x))};
\end{axis}
\end{tikzpicture}
% -------------------------------------------------------- %
\end{figure}
\lipsum[2]



% == A second plot ======================================= %
\section{A second plot}

\lipsum[3]
\begin{figure}[h]
\centering
% -------------------------------------------------------- %
\tikzsetnextfilename{second-plot}
\begin{tikzpicture}
\begin{loglogaxis}
[xlabel=Dof,ylabel=Error,
 width=\textwidth]
\addplot file{datafile1a.dat};
\addplot file{datafile1b.dat};
\legend{Case 1,Case 2}
\end{loglogaxis}
\end{tikzpicture}
% -------------------------------------------------------- %
\end{figure}
\lipsum[4-5]



% == A third plot ======================================== %
\section{A third plot}

\lipsum[6]
\begin{figure}[hbtp]
\centering
% -------------------------------------------------------- %
\tikzsetnextfilename{third-plot}
\begin{tikzpicture}
\begin{loglogaxis}[xlabel=Dof,ylabel=Error,width=\textwidth]
\addplot table[x=dof1,y=error1] {datafile2.dat};
\addplot table[x=dof2,y=error2] {datafile2.dat};
\legend{Case 1,Case 2}
\end{loglogaxis}
\end{tikzpicture}
% -------------------------------------------------------- %
\end{figure}
\lipsum[7]


\end{document}

Terminal command: latex -shell-escape example.tex

Further information (1) black background Check the figure in https://www.dropbox.com/sh/gyxm8gzd2p5jfdu/AABqrV27uLmoxut0Qu98mCQca?dl=0. (2) Texmaker Version 4.5 is used. (3) File List

 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  lipsum.sty    2011/04/14 v1.2 150 paragraphs of Lorem Ipsum dummy text
    tikz.sty    2010/10/13 v2.10 (rcs-revision 1.76)
     pgf.sty    2008/01/15 v2.10 (rcs-revision 1.12)
  pgfrcs.sty    2010/10/25 v2.10 (rcs-revision 1.24)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v2.10 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
   dvips.def    1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
  pgfsys.sty    2010/06/30 v2.10 (rcs-revision 1.37)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v2.10 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v2.10 (rcs-revision 1.1)
  pgffor.sty    2010/03/23 v2.10 (rcs-revision 1.18)
 pgfkeys.sty    
 pgfkeys.code.tex
  pgffor.code.tex
    tikz.code.tex
pgfplots.sty    2013/10/03 v1.9 Data Visualization (1.9)
fig/first-plot.eps
fig/second-plot.eps
fig/third-plot.eps
 ***********

File List article.cls 2014/09/29 v1.4h Standard LaTeX document class size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option) lipsum.sty 2014/07/27 v1.3 150 paragraphs of Lorem Ipsum dummy text tikz.sty 2015/08/07 v3.0.1a (rcs-revision 1.151) pgf.sty 2015/08/07 v3.0.1a (rcs-revision 1.15) pgfrcs.sty 2015/08/07 v3.0.1a (rcs-revision 1.31) everyshi.sty 2001/05/15 v3.00 EveryShipout Package (MS) pgfrcs.code.tex pgfcore.sty 2010/04/11 v3.0.1a (rcs-revision 1.7) graphicx.sty 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) keyval.sty 2014/10/28 v1.15 key=value parser (DPC) graphics.sty 2016/07/10 v1.0t Standard LaTeX Graphics (DPC,SPQR) trig.sty 2016/01/03 v1.10 sin cos tan (DPC) graphics.cfg 2016/06/04 v1.11 sample graphics configuration dvips.def 2016/07/10 v3.1a Driver-dependent file (DPC,SPQR) pgfsys.sty 2014/07/09 v3.0.1a (rcs-revision 1.48) pgfsys.code.tex pgfsyssoftpath.code.tex 2013/09/09 (rcs-revision 1.9) pgfsysprotocol.code.tex 2006/10/16 (rcs-revision 1.4) xcolor.sty 2016/05/11 v2.12 LaTeX color extensions (UK) color.cfg 2016/01/02 v1.6 sample color configuration pgfcore.code.tex pgfcomp-version-0-65.sty 2007/07/03 v3.0.1a (rcs-revision 1.7) pgfcomp-version-1-18.sty 2007/07/23 v3.0.1a (rcs-revision 1.1) pgffor.sty 2013/12/13 v3.0.1a (rcs-revision 1.25) pgfkeys.sty
pgfkeys.code.tex pgfmath.sty
pgfmath.code.tex pgffor.code.tex tikz.code.tex pgfplots.sty 2016/08/10 v1.14 Data Visualization (1.14) pdftexcmds.sty 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO) infwarerr.sty 2016/05/16 v1.4 Providing info/warning/error messages (HO) ifluatex.sty 2016/05/16 v1.4 Provides the ifluatex switch (HO) ltxcmds.sty 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) ifpdf.sty 2016/05/14 v3.1 Provides the ifpdf switch atveryend.sty 2016/05/16 v1.9 Hooks at the very end of document (HO) fig/first-plot.eps fig/second-plot.eps fig/third-plot.eps


After updating to the latest version, the problem is still there.

  • Welcome to TeX.SX! Can you please provide a complete, small LaTeX document that shows the behaviour that you describe, starting with \documentclass and ending with \end{document}? This makes it easier for us to understand and investigate the problem. Just use the edit button to add the code to your post. – gernot Oct 03 '16 at 14:21
  • From this link http://roth.cs.kuleuven.be/w-ess/index.php/Creating_LaTeX_figures_with_the_use_packages_tikz_and_pgfplots#Export_as_eps, section "Export as eps", source code http://roth.cs.kuleuven.be/w-ess/index.php/File:Example-export-eps.tar.bz2, terminal command latex -shell-escape example.tex – Jiadun Liu Oct 03 '16 at 19:05
  • The pdf/ps files generated from this site look perfectly normal, without black background. Can you check the log files (also those in the fig subdirectory) for error messages or warnings? Moreover, what do you mean by black background? Are the plots missing altogether, or are they surrounded by a black border? Last point: Which TeX distribution do you use? TeXLive 2016 or an older one? Add the command \listfiles as the first line of example.tex and post the lines from example.log between *File List* and ***********. – gernot Oct 04 '16 at 17:16
  • Check the figure in https://www.dropbox.com/sh/gyxm8gzd2p5jfdu/AABqrV27uLmoxut0Qu98mCQca?dl=0. Texmaker Version 4.5 is used. – Jiadun Liu Oct 05 '16 at 08:18
  • Your TeX distribution (not Texmaker, this is just a tool on top, a kind of "intelligent" editor) is outdated. Relevant packages are tikz (you have version 2.10 from 2010, the current version is 3.0.1a from 2015) and pgfplots (you have 1.9 from 2013, the current version is 1.14 from 2016). It is hardly possible to analyze your problem anywhere else than on your computer, and the result most probably will be: update your TeX distribution to get rid of the old bugs. – gernot Oct 05 '16 at 09:14

0 Answers0