0

td;dr: How can I reliably reduce the number of layers in a PDF that contains pgfplotswith lots of data point.

I have made some 3D plots using pgfplots which each contain a lot of data points. They are typeset as PDF via standalone and included in the main document using graphicx:

enter image description here

I went to two local copy shops to have my document (containing roughly 20 of them included via graphicx) printed, but was told these plots cause my document to contain "too many layers" and their printing setup to "hang". I can print it without issues from a MacBook on a rather cheap consumer Canon ink jet printer, however.

Please don't suggest manual conversion to bitmaps. If conversion is absolutely required, I need to do it with the whole document and in an automatic way. There's no time to do it manually plot-by-plot.

Please also don't suggest reducing the data. The plots do look fine, compile within reasonable time (~1 min on my machine) and I absolutely cannot touch the data anymore right now.

Heres the MWE and the sample csv data can be found here on my github.

% !TeX program = lualatex
\RequirePackage{luatex85}
\documentclass[border={1.5cm 2pt 5mm 10pt}]{standalone}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{siunitx}

%\usepackage[no-math]{fontspec}
%\setmainfont{Linux Libertine}
%\setsansfont{Linux Biolinum}
\usepackage[partial=upright]{unicode-math}
\usepackage{fontspec}
\usepackage{xcolor}

\usepackage{tikz}
\usetikzlibrary{
    pgfplots.groupplots
}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{pgfplotstable}

\usepackage[main=ngerman,english]{babel}

\begin{document}

\begin{tikzpicture}[trim axis left,trim axis right]
    \begin{axis}[
        width=7cm,
        grid=both,
        view={120}{45},
        set layers,
        every axis plot/.append style={on layer=pre main},
        every x tick scale label/.style={
            overlay,
            at={(xticklabel* cs:0.8)},
            anchor=near xticklabel,
            inner sep=8pt,
        },
        xmin=0,
        xmax=0.01,
        ymode=log,
        ytick={0.01,0.1,1,10},
        ymin=0,
        ymax=30,
        zmin=20,
        zmax=420,
        ztick={20,200,420},
        zlabel={Quantity},
        clip=false
    ]
    \addplot3[
            surf,
            opacity=0.05,
            fill opacity=0.75,
            shader=flat,
            colormap/viridis,
        ] table [
            col sep=comma,
        ] {data.dat};
    \node at (rel axis cs:0.5,0,1) [overlay,above,sloped like x axis] {Axis A};
    \node at (rel axis cs:0,0.5,1) [overlay,above,sloped like y axis] {Axis B};
    \end{axis}
\end{tikzpicture}

\end{document}

Edit: By the way, this is the how the mininimal working example is rendered in Adobe Acrobat Reader 11.0.23 on a Windows 10 machine (please oversee the axis labels which I have changed here):

enter image description here

This is obviously not acceptable and I wonder what's wrong with my code that only Acrobat fails to display it correctly. Works under Ubuntu using Eye of Gnome or qpdfview as well as under OSX using Preview.

  • well you don't leave much options to us. What do they mean by layers?Then the only option is find a proper printer – percusse Apr 27 '18 at 13:23
  • I really don't know :( – Christoph90 Apr 27 '18 at 13:23
  • Then we can't know either. This is not a well defined question – percusse Apr 27 '18 at 13:24
  • 1
    You may want to consider shader=interp. On my system, acrobat reader displays the result fine (and much faster) although it was slow and wrong with the original report. Interestingly, xpdf fails to display the combination shader=interp,* opacity... that's new to me. shader=interp is not what you had in mind, I know. And you may also need to combine it with \usepackage[cmyk]{xcolor} in order to avoid color burning (try it, you'll see what I mean). – Christian Feuersänger Apr 28 '18 at 10:50
  • 1
    Actually, I am wondering why acrobat reader applies the stroke opacity to the boundaries of the flat rectangles. Is this a bug in pgfplots? I added \let\pgfplotsplothandlermeshusepathfillstroke=\pgfplotsplothandlermeshusepathfill experimentally and the display is fine. Perhaps this would also fix the printing issue? – Christian Feuersänger Apr 28 '18 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.