[Tex/LaTex] inset plot with pgfplots

pgfplotsplot

I am using pgfplots to plot some data I have, and I wanted to generate a large plot with another plot inside of it, showing a zoom on a region of the large plot.
I have noticed that when you do

\begin{tikzpicture}
 \begin{axis}[width=0.45\textwidth]
  %small plot
 \end{axis}
 \begin{axis}[width=\textwidth]
  %large plot
 \end{axis}
\end{tikzpicture}

the second plot starts at the same position than the first one. Is there a way to move the origin of the small plot to an empty region of the big one?
Or maybe you know a better alternative…

thanks

Best Answer

You could use the xshift, and yshift keys:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[xshift=.5\textwidth,yshift=2cm,width=0.45\textwidth]
  %small plot
 \end{axis}
 \begin{axis}[width=\textwidth]
  %large plot
 \end{axis}
\end{tikzpicture}

\end{document}