Taking the MWE from Jake's answer to the question Background rectangles with equal width but 'fitting' height, I get an error when loading pgfplots after the tikz packages but not before. I'm assuming this is caused by pgfplots redefining the standard tikz layers (cf. tikz manual Section 4.26) but I don't quite understand if this is intentional and whether loading pgfplots before tikz has any consequences for how pgfplots expects its layers to work.

The error in question is:

! Package pgf Error: Sorry, the requested layer 'background' is not part of the 
layer list. Please verify that you provided \pgfsetlayers and that 'background' 
is part of this list.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.

l.49     \begin{pgfonlayer}{background}



\usepackage{pgfplots} % Works fine
%\usepackage{pgfplots} % Throws an error


        rounded corners,
        inner xsep=2em,

% Returns three nodes: The argument, and the projections of the argument on the left and right borders of the bounding box
    ($(current bounding box.north east)!(#1)!(current bounding box.south east)$)
    ($(current bounding box.north west)!(#1)!(current bounding box.south west)$)

\matrix (matrix) [row sep=0.5cm,column sep=0.5cm] {
  \node (elicit) [schritt] {Wissenserhebung}; & \\
  \node (interpret) [schritt] {Interpretation}; & \\
  & \node (model) [schritt] {Modellierung}; \\
  \node (representation) [schritt] {Repräsentation}; & \\
  \node (integration) [schritt] {Integration}; & \\
  \node (maintenance) [schritt] {Wartung}; & \\

  (elicit) edge (interpret)
  (interpret) edge node[right] {\hspace{.35cm}\tiny Modellbasierter Ansatz} (model)
  (interpret) edge node[right] {\tiny Rapid Prototyping} (representation)
  (model) edge (representation)
  (representation) edge (integration)
  (integration) edge (maintenance);


  \path [use as bounding box] (current bounding box.north west) (current bounding box.south east); % Freeze current bounding box
  \node [fit={\extendnode{elicit}}, background] {First};
  \node [fit={\extendnode{interpret} (model)}, background] {Second};
  \node [fit=\extendnode{representation}, background] {Third};
  \node [fit=\extendnode{integration}, background] {Fourth};
  \node [fit=\extendnode{maintenance}, background] {Fifth};


  • 2
    You don't need to load TikZ anyways. It's loaded by pgfplots and Tikz doesn't have any options to change so it's redundant. Just let pgfplots do its magic internally. – percusse Mar 24 '13 at 1:10
  • @percusse That would solve it, alright, since any \usetikzlibrary will necessarily come after pgfplots is loaded anyway. I'm guessing that means that loading tikz second would not interfere with the layers pgfplots establishes then, as pgfplots presumably takes care of that when loading tikz in its own code. – ThomasH Mar 24 '13 at 1:41
  • It won't interfere because that statement would be ignored completely since TikZ is already loaded. See for example this one for a bit better explanation tex.stackexchange.com/a/25673/3235 – percusse Mar 24 '13 at 2:02
  • 1
    your MWE works fine for me- perhaps How do I update my TeX distribution? – cmhughes Mar 24 '13 at 3:32
  • I encountered this error message using TeXLive 2012 (not upgraded). Switching to TeXLive 2013 and using \pgfplotsset{compat=newest} (which uses version 1.10) solved the problem. – josteinb Aug 12 '14 at 21:12

Pgfplots must not interfere with layers of TikZ.

The only allowed relation is if a TikZ picture contains a pgfplots element (an axis): in this case, the axis should merge into TikZ's layers (if and only if layered graphics has been enabled manually and explicitly for that image).

What you experience is a bug; probably in your version of pgfplots.

I am aware of the fact the version 1.7 fixed some "compatibility regression" which has been introduced in pgfplots 1.6.1 and which exists if pgf with version 2.10 (the current stable) is used.

An upgrade to pgfplots 1.7 (or 1.8) should help. Note that pgfplots 1.8 should be available on CTAN within the next days and is already available on http://sourceforge.net/projects/pgfplots/, so it might be simpler to upgrade to that version rather than 1.7. But 1.7 does the job.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.