# Drawing coordinate system with tikz and changing offset, spacing etc

I am trying to draw a coordinate system with tikz on top of a picture. I am trying to re-recreate the coordinate system in the attached figure as a test, but I have a few problems

1. How do I change the offset of the coordinate system so it is right at the south-west corner of the figure?
2. How do I change the spacing of the x- and y-axis so that they run from a min-value to a max-value with a step I decide?

My code is the following so far. This draws the coordinate system, but now I have to move it to the corner and change the spacing and max/min values:

\documentclass[border=30pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=\textwidth]{test.jpg}};

\tkzInit[xmax=8,ymax=1,xmin=0,ymin=0]
\tkzAxeXY
\end{tikzpicture}
\end{document}


• You can check this question.
– Kpym
Commented Oct 16, 2016 at 11:05
• Why don't you use pgfplots? Commented Oct 16, 2016 at 14:01
• @EnricoMariaDeAngelis I am very interested to see an example of how to do it with pgfplots Commented Oct 20, 2016 at 12:09
• @BillyJean, I added my answer. Hope it's good. Commented Oct 20, 2016 at 13:05

This should be more readable and working:

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0,xmax=7,ymin=0,ymax=7,
xtick={0,1.333,...,7},
ytick={0,1,...,7},
view={0}{90}]
coordinates {
(0,0,0) (7,0,0)

(0,7,1) (7,7,1)
};
\end{axis}
\end{tikzpicture}
\end{document}


• Thanks, this is much more readable. Is is possible to shift the position of the coordinate system? Right now I am plotting the axes on top of a figure I load in externally using  \node [inner sep=0pt] (c) {\includegraphics[scale=1]{urxul.jpg}};, and I need to move the coordinate system to the corner of this picture Commented Oct 20, 2016 at 13:24
• Maybe I don't understand what you mean by position of the coordinate system. If you're talking about the origin of the CS, then you can just set negative xmin and ymin in order to have the origin in the inner part of the axis. You could add a hand sketch of what you want to your question. Commented Oct 20, 2016 at 13:43
• Thanks, that worked. A final question, I hope this is alright: Is it possible to scale the x- and y-axis independently? So I can set their length manually. Right now I am using width=4cm, but this changes both axes Commented Oct 20, 2016 at 13:46
• Check this Commented Oct 20, 2016 at 13:49
• Thanks, you really pushed me forward. I ended up using your solution, it is IMO much simpler to grasp Commented Oct 20, 2016 at 14:00

You can just draw over the image in the way the links you've been directed to illustrate. A few loops save typing, but that's all.

\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node [inner sep=0pt] (c) {\includegraphics[scale=3]{changeable}};
\begin{scope}[shift=(c.south west), x=(c.south east), y=(c.north west)]
\coordinate (x0) at (1,0);
\path (0,0) \foreach \i in {1,...,8} { ++({1/8.1},0) node (x\i) [below, font=\scriptsize] {\i 0} edge [thin] +(0,2.5pt)};
\path (0,1) coordinate (y0) \foreach \i in {1,...,8} { ++(0,-{1/8.1}) node (y\i) [left, font=\scriptsize] {\i 0} edge [thin] +(2.5pt,0)};
\foreach \i in {1,...,8} \draw [thin] (y0 -| x\i) edge [gray!50, thin] +(0,-2.5pt) (x0 |- y\i) -- +(-2.5pt,0);
\end{scope}
\end{tikzpicture}
\end{document}