# How can you add a drop shadow to a pgfplots axis?

Using the shadows TikZ library, we can add a drop shadow to a rectangle. Is there a way to add the same effect to the boxed axis of a pgfplots picture? Here is a minimal example:

\documentclass{minimal}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\draw[fill=white, drop shadow] (0,0) rectangle (5, 5);
\end{tikzpicture}

\vspace*{1.0\baselineskip}
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
\end{document}


which produces this:

Two options:

1. Working inside the axis environment, you can use the native layer system of pgfplots together with the rel axis coordinate system to add the shadow (requires clip=false):

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[set layers,clip=false]
\draw[fill=white, drop shadow,on layer=axis background]
(rel axis cs:0,0) rectangle (rel axis cs:1,1);
\end{axis}
\end{tikzpicture}
\end{document}


2. Working outside the axis environment, you can name the axis and then use the name to place the shadow on the background using the tikz backgrounds library:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[name=myaxis]

As a side note, pgfplots internally loads TikZ, so no need to load the latter when you load the former. The minimal class is meant to serve to test an installation with something like the classic "Hello world!". I'd suggest you not to use if for anything more complex than that.