# How to properly place an object based on axis?

I would like to place a rectangle in one of my graphs. However it seams that I am mixing dimensions. Is there a way to make sure that \draw uses the same dimension and would fill what is currently enclosed by "estimates"?

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\usepackage{verbatim}

\begin{document}
\centering

\begin{tikzpicture}
\begin{axis}[
width=0.8\textwidth,
height=0.4\textwidth,
]
(1,1)
(1,2)
(2,2)
(2,1)
(1,1)
};
\end{axis}

\draw[fill=blue] (1,1) rectangle (2,2);
\end{tikzpicture}

\end{document}

-
I have also tried moving the $\draw$ inside the $axis$ environment but that's not the solution either. –  MatoBehr Apr 22 at 10:23
Here is a help how you can mark your inline code. $...$ should be used only for math mode code. –  Christian Hupfer Apr 22 at 10:28

Place the \draw inside the axis and use the axis cs coordinate system, as in \draw[fill=blue] (axis cs:1,1) rectangle (axis cs:2,2);

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\usepackage{verbatim}

\begin{document}
\centering

\begin{tikzpicture}
\begin{axis}[
width=0.8\textwidth,
height=0.4\textwidth,
]
(1,1)
(1,2)
(2,2)
(2,1)
(1,1)
};