# Drop shadow of node with pgfplot inside

I have this code:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
};
\path [use as bounding box] (-5,-5) rectangle (5,5);
\end{tikzpicture}
\end{document}


which gives

The problem is now that the plot has also a drop shadow. How can I avoid this? I tried to use fill either in pre- or postaction or changing the pgfplot background to white but that dind't help.

• Why are you including the tikzpicture with the plot inside the \node? Can you describe what you are trying to achieve? – Gonzalo Medina Feb 2 '14 at 17:48
• I want to connect different nodes in a flow diagram. – Reza Feb 2 '14 at 18:14

The inner nodes will inherit the shadow; that's why is not, generally speaking, a good idea to nest tikzpicrures.

You can use a background layer to add the colored background:

\documentclass[tikz,border=5pt]{standalone}
\usepackage{pgfplots}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\end{axis}
\begin{pgfonlayer}{background}
([yshift=3pt]current bounding box.north west) rectangle ([xshift=3pt]current bounding box.south east);
\end{pgfonlayer}
\end{tikzpicture}

\end{document}


In a comment it has been requested to have two plots, each one with a colored background and a drop shadow and both connected with an arrow; this can be done by saving the plots in boxes (safe method for nesting tikzpictures) and then using nodes to place them and draw the arrow. An example:

\documentclass[tikz,border=5pt]{standalone}
\usepackage{pgfplots}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\newsavebox\myboxa
\newsavebox\myboxb

\savebox\myboxa{%
\begin{tikzpicture}
\begin{axis}
\end{axis}
\begin{pgfonlayer}{background}
([yshift=3pt]current bounding box.north west) rectangle ([xshift=3pt]current bounding box.south east);
\end{pgfonlayer}
\end{tikzpicture}%
}
\savebox\myboxb{%
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {(0,0) (0.4,0.6) (0.7,0.2) (1,1)};
\end{axis}
\begin{pgfonlayer}{background}
([yshift=3pt]current bounding box.north west) rectangle ([xshift=3pt]current bounding box.south east);
\end{pgfonlayer}
\end{tikzpicture}%
}

\begin{document}

\begin{tikzpicture}
\node (a) {\usebox\myboxa};
\node[right=of a] (b) {\usebox\myboxb};
\draw[->] (a) -- (b);
\end{tikzpicture}

\end{document}

• thanks for your solution! What would be the correct way to connect 2 nodes with pgfplots inside, instead of nesting the pgfplots inside the nodes? – Reza Feb 2 '14 at 18:23
• @Reza I am not sure what you are asking. Do you have two plots and you want to connect some points from one of them to some points of the other? – Gonzalo Medina Feb 2 '14 at 18:25
• sorry for my bad explanation. I have two nodes with a pgfplot inside and I want just to have drop shadow on every node and connect them with an arrow: \draw[->] (node1) -- (node2); – Reza Feb 2 '14 at 18:28
• @Reza Ah, now I see. Please see my updated answer. – Gonzalo Medina Feb 2 '14 at 19:05
• cool thanks, exactly what I was looking for! Since which version is this possible? – Reza Feb 2 '14 at 19:14