[Tex/LaTex] Background image for pgfplots chart

backgroundspgfplots

Following up on the answer to proper tool for charts in tex I've built this picture to simulate/replace a scanned image from a newspaper:

enter image description here

I've tried several ways to put the background newsprint image behind the whole figure (axis labels and titles) as well as the chart, with no success.

When that's done, I'd like to have ragged edges, as in @Ipsens's answer to
Torn page effect

Here's my MWE (not absolutely minimal, but small enough). The newsprint image is
http://www.theblockforum.com/fun/lance/lancescollection/textures/paper2.jpg

Edit: Drawing on an image with TikZ might be helpful, but I couldn't get the example there to compile.

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{backgrounds}

%deal with warning message in log
\pgfplotsset{compat=1.8}

\newcommand{\mywidth}{10cm}
\newcommand{\myheight}{7cm}

%https://tex.stackexchange.com/questions/35872/multiline-coords
\pgfplotstableread[col sep=comma]{
name, footprint
Google search, 0.2
Movie download, 20
Daily newspaper, 170
}\carbonfootprints

\begin{document}
\begin{tikzpicture}[font=\sffamily]

\begin{pgfonlayer}{background}
   \includegraphics{newsprint}
\end{pgfonlayer}

\begin{axis}[ 
      xbar, xmin=0,
      tick style={draw=none},
      width=\mywidth, height=\myheight, 
      enlarge y limits=0.5,
      xlabel={Estimated carbon footprint, g CO${}_2$}, 
      ytick=data,
      yticklabel style={align=right},
      yticklabels={
        Google\\ search, 
        Movie\\ download,
        Daily\\ newspaper,
      },
      nodes near coords,
      nodes near coords align={horizontal}, 
    ]
    \addplot [fill=red] table [x=footprint, y expr=\coordindex] 
             {\carbonfootprints};
\end{axis} 

\end{tikzpicture}
\end{document}

Best Answer

The idea is to use the pencildraw style from Ipsenss answer to do a clipping before the axis environment; after the axis environment a \node is used to include the background image using a background layer:

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{calc,decorations.pathmorphing}

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

%deal with warning message in log
\pgfplotsset{compat=1.8}

\definecolor{paper}{RGB}{239,227,157}

\newcommand{\mywidth}{10cm}
\newcommand{\myheight}{7cm}

%http://tex.stackexchange.com/questions/35872/multiline-coords
\pgfplotstableread[col sep=comma]{
name, footprint
Google search, 0.2
Movie download, 20
Daily newspaper, 170
}\carbonfootprints

\tikzset{
pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=2pt,amplitude=1pt}
    } %
}

\begin{document}
\begin{tikzpicture}[font=\sffamily]
\path[clip,pencildraw] (-2.5,-40pt) rectangle (9,6);
\begin{axis}[
      xbar, xmin=0,
      tick style={draw=none},
      width=\mywidth, height=\myheight, 
      enlarge y limits=0.5,
      xlabel={Estimated carbon footprint, g CO${}_2$}, 
      ytick=data,
      yticklabel style={align=right},
      yticklabels={
        Google\\ search, 
        Movie\\ download,
        Daily\\ newspaper,
      },
      nodes near coords,
      nodes near coords align={horizontal}, 
    ]
    \addplot [fill=red] table [x=footprint, y expr=\coordindex] 
             {\carbonfootprints};
\begin{pgfonlayer}{background}
\node {\includegraphics{papiro}};
\end{pgfonlayer}
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here