I need to draw two rectangles (or this could apply to any shape in general) of different colors on top of a diagram.
The MWE that I have this is. The code works, but I am unable to change the coordinates of the squares to accurately achieve my desired result. I have been drawing using the tikzpicture.
My MWE is the following:
\documentclass[10pt, compress]{beamer}
\usepackage{tikz}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=\textwidth]{images/sample.png}};
\draw[red,ultra thick,rounded corners] (5.3,5.3) rectangle (8.4,8.4);
\draw[green,ultra thick,rounded corners] (3.4,3.4) rectangle (8.3,8.3);
\end{tikzpicture}
\end{frame}
\end{document}
This MWE correctly draws the rectangles on top of the image, but they are incorrectly placed over it.
The desired result is along this line:
However, at the moment, I am achieving the following result:

Can someone provide insight on how to best estimate the coordinates that will help me get to my desired output? This problem has been recurrent for me for several tasks - so I would like to understand how to calculate them. Thank you!

pgfplotsand use theaxis cscoordinate system to accurately draw on your graph in the "natural" coordinates of the graph, i.e. whatever your axes are labeled with. As such, I think it is a duplicate, unless you can be more specific about what your problem is :-) – darthbith Mar 03 '15 at 17:59