# How can I draw an axis with values on some points?

I think the figure is very simple.

Nevertheless, I can't figure out how to do it. Any help?

-
Related (but more advanced usage) question: Creating a line of given length with variable number of “snags” equally separated (TikZ)? – Peter Grill Apr 21 '12 at 19:03

A very basic approach just to show the concept.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (6,0);
\foreach \x/\xtext in {0/a,1/b,3/c,6/d}{
\draw (\x cm,-2pt) -- (\x cm,2pt) node[above] {\xtext};
}
\end{tikzpicture}
\end{document}


For details you should take a look into the »pgf/tikZ« user guide.

-

I prefer an answer instead of a long comment but I want to say that it's preferable to use the same method to work with dimensions

If you wrote \draw (0,0) -- (6,0); then the code would be :

 \documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (6,0);
\foreach \x/\xtext in {0/a,1/b,3/c,6/d}{
\draw (\x ,-.08) -- (\x,0.08) node[above] {\xtext};
}
\end{tikzpicture}


A problem can appear if later you use scale = 2 or x= 2 cm, y = 2 cm or if you want to use big numbers.

Why is important :

 \documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0)--(600,0);
\end{tikzpicture}
\end{document}


gives an error Latex Error : ... Dimension too large.

 \documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.01 cm]
\draw (0,0)--(600 cm,0);
\end{tikzpicture}
\end{document}


gives the same error

but

 \documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.01 cm]
\draw (0,0)--(600,0);
\end{tikzpicture}
\end{document}
\end{document}


is correct. a dim is limited by 16 384 pt near 5.75 m but TeX can work with big numbers, the next code compiles but you can't replace x=0.00001 cm by x=0.000001 cm

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.00001 cm]
\coordinate (x) at (600000,0);
\draw (0,0)--(x);
\end{tikzpicture}
\end{document}

-
A very interesting aspect. Good to know. – Thorsten Donig Apr 22 '12 at 10:09