# How to draw a time diagram

How to draw the following diagram in latex?

I would be grateful to know how to put another text above 100 (for example 200 above 100 and $AV_{X}$ above $AV_{Y}$)?

If you add align=center (or align=left or align=right) to the options of a node, you can use \\ in the node text to add line breaks.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (2,0);
% \x/\y/\z = label below/label above/label on top
\foreach \x/\y/\z in {0/100/200,1//,2/$AV_Y$\rlap{=?}/$AV_X$}
\draw (\x,-2mm) node[below]{\x} -- ++(0,4mm) node[above,align=center] {\z\\\y};
\end{tikzpicture}
\end{document}


A small variation of @js bibra answer (+1):

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (4,0);
\foreach \i [count=\x from 0] in {100, ,$AV_Y{=}?$}
{
\draw[thick] (2*\x,2mm) node[above] {\i} -- ++ (0,-4mm) node[below] {\x};
}
\end{tikzpicture}
\end{document}


Addendum: In above answer I forgot on nodes in the second row above ticks. They can be add as two line content of nodes. For this nodes should have option align=center as suggest @gernot in his answer (+1):

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[every node/.append style={align=center}]
\draw[thick] (0,0) -- (4,0);
\foreach \i [count=\x from 0] in {200\\100, ,$AV_X$\\$AV_Y{=}?$}
{
\draw[thick] (2*\x,2mm) node[above] {\i} -- ++ (0,-4mm) node[below] {\x};
}
\end{tikzpicture}
\end{document}


• in respect to js bibra, this one looks more similar to the image OP has, directed at the OP if he cares about the similarity. Oct 8, 2021 at 13:09
• Fair chance OP needs this: ibb.co/S3ghc6b Oct 8, 2021 at 13:15
• I see that you have added the double lines +1. Also I am not the OP (to clear any confusion). Oct 10, 2021 at 13:29

\documentclass[tikz, margin=3mm]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\draw[line width=1pt] (0,0)node(a){} -- (8,0)node(b){}[right=4mm];
\foreach \x/\y in {100/0,/1,{$AV_Y$}=?/2}%
{
\draw[line width=1pt] (4*\y,-2mm) node[below] {\y} -- ++(0,4mm) node[above] {\x};
}
\end{tikzpicture}
\end{document}


To have additional text above the start and end labels which are currently present (i.e: 200 over 100)

\documentclass[tikz, margin=3mm]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\draw[line width=1pt] (0,0)node(a){} -- (8,0)node(b){}[right=4mm];
\foreach \x/\y/\z in {100/0/200,\phantom{1}/1/\phantom{1},{$AV_Y$}=?/2/{$AV_X$}\phantom{=?}}%
{
\draw[line width=1pt] (4*\y,-2mm) node[below]() {\y} -- ++(0,4mm) node[above](n\y) {\x};
\node[above=1ex of n\y] {\z};
}
\end{tikzpicture}
\end{document}


• Fair chance OP needs this: ibb.co/S3ghc6b Oct 8, 2021 at 13:15
• @860009898987 please have a look at the edited answer Oct 8, 2021 at 13:59
• Yes that's what I was pointing +1. Also I think you pinged OP instead of me (I am not the OP), I mean the number! Oct 10, 2021 at 13:27