# TikZ \draw creates very tiny lines

I'm trying to create vertical lines in a tikzpicture, but they're being drawn at very small scales.

My code:

\documentclass [10pt] {article}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xmin=-0.25,
xmax=3.5,
ymin=-0.25,
ymax=1.75,
axis line style={<->},
]
\draw (1,-0.25) -- (1,1.75)[dashed,gray];
\draw (2,-0.25) -- (2,1.75)[dashed,gray];
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}


And this is the problem:

If you can see it, all the way in the bottom left corner, there are the two tiny vertical lines that I wanted to span from (1,-0.25) to (1,1.75) and from (2,-0.25) to (2,175). If I set the ranges to something massive like 500, I can see the lines, but I don't understand why they're being drawn this way.

You must specify that you want to use the axis coordinate system (axis cs):

\documentclass [10pt] {article}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xmin=-0.25,
xmax=3.5,
ymin=-0.25,
ymax=1.75,
axis line style={<->},
]
\draw (axis cs:1,-0.25) -- (axis cs:1,1.75)[dashed,gray];
\draw (axis cs:2,-0.25) -- (axis cs:2,1.75)[dashed,gray];
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

• From version 1.11 it is done automatically. You don't need to add. – percusse Jan 28 '16 at 1:43
• This fixes it, thanks. I've never had to do this before though, I can't understand why I suddenly need to add it. – Emilio Garcia Jan 28 '16 at 1:46
• @EmilioGarcia you don't need to. See my comment in the other answer. – percusse Jan 28 '16 at 1:54
• @percusse I see, the version declaration also fixes the problem. I've never had to do either though. I don't understand what about this graph requires compat. – Emilio Garcia Jan 28 '16 at 1:59
• The default axis coordinates for pgfplots before 1.11 was the normalized one (from 0,0 to 1,1). It has been changed to the coordinates in the plot, but for compatibility with older sources you need to ask specifically for it. (Thanks \${DEITY})You should have a compat key anyway, because without it there are very old and buggy behaviour s active. – Rmano Jan 28 '16 at 6:51

You should specify the coordinates relative to your axes using (axis cs:x,y), or just use @percusse's advice and put \pgfplotsset{compat=1.12} in the preamble without changing your original code.

\documentclass [10pt] {article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xmin=-0.25,
xmax=3.5,
ymin=-0.25,
ymax=1.75,
axis line style={<->},
]

• @EmilioGarcia The problem should be about adding \pgfplotsset{compat=1.12} – percusse Jan 28 '16 at 1:43