# [Tex/LaTex] Why is this Tikz scope coordinate system skewed

positioningtikz-pgf

I'm trying to create a simple figure in which the tick labels will not line up properly, because the coordinate system is skewed. Here is the MWE code:

\documentclass[a4paper,twocolumn]{article}

\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}

\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}
\node[anchor=south west, inner sep=0] (image) at (0.3,0.2) {\includegraphics[width=0.8\columnwidth]{asmmodes}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw (-0.02, 0.833) node [right]{1};
\draw (-0.02, 0.5) node [right]{2};
\draw (-0.02, 0.167) node [right]{3};
\draw (0.07, -0.03) node [text centered,above]{-4};
\draw (0.22, -0.03) node [text centered,above]{-2};
\draw (0.37, -0.03) node [text centered,above]{-1};
\draw (0.50, -0.03) node [text centered,above]{0};
\draw (0.65, -0.03) node [text centered,above]{1};
\draw (0.79, -0.03) node [text centered,above]{2};
\draw (0.94, -0.03) node [text centered,above]{4};
\draw (0.5, -0.03) node [text centered,below]{standard deviations};
\draw (-0.04, 0.5) node [text centered]{\rotatebox{90}{first three model shape parameters}};
\draw [thick,red] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
\end{scope}
\end{tikzpicture}
\end{center}
\label{fig:asmmodes1}
\end{figure}

\end{document}


This gives me the following output:

As you can see the tick labels are not lined up nicely because the coordinate system is skewed. I'm not sure what to do about this. Can someone help me out here?

First problem: when you change x and y without changing the origin, your axis are not orthogonal. You have to shift the origin to image.south west.

Second problem: the anchors of image are not on the borders of the included image because outer sep is not null. You have to add outer sep=0 to remove this margin.

Instead of \rotatebox, you may use rotate option.

\documentclass[margin=1mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west, inner sep=0,outer sep=0] (image)
at (0.3,0.2) {\includegraphics[width=0.8\columnwidth] {example-image-a}};
\begin{scope}[
shift=(image.south west),
x={(image.south east)},y={(image.north west)}
]
\draw (-0.02, 0.833) node [right]{1};
\draw (-0.02, 0.5) node [right]{2};
\draw (-0.02, 0.167) node [right]{3};
\draw (0.07, -0.03) node [text centered,above]{-4};
\draw (0.22, -0.03) node [text centered,above]{-2};
\draw (0.37, -0.03) node [text centered,above]{-1};
\draw (0.50, -0.03) node [text centered,above]{0};
\draw (0.65, -0.03) node [text centered,above]{1};
\draw (0.79, -0.03) node [text centered,above]{2};
\draw (0.94, -0.03) node [text centered,above]{4};
\draw (0.5, -0.03) node [text centered,below] {standard deviations};
\draw (-0.04, 0.5) node [text centered,rotate=90] {first three model shape parameters};
\end{scope}
\end{tikzpicture}
\end{document}