# How to create axis with annotations?

I want to get horizontal axis with annotations, like in attached picture. What package would be most suitable for such task?

• welcome to tex.se! what you try so far? – Zarko May 6 '19 at 17:56
• Hello! I didn't try anything so far. I came here, because maybe someone had such case before. – Piotr Bródka May 6 '19 at 19:16
• similar question are appears here, you need to search site. at least you should provide more information about your document (used packages, etc). otherwise this is do-it-for-me question, which likely be closed soon as "to broad" . – Zarko May 6 '19 at 19:20

Here is a starter with simple \put commands:

\documentclass{article}
\unitlength=1cm
\begin{document}

\begin{picture}(6,3)(-0.5,-1.5)
\put(0,0){\vector(1,0){5}}\put(5.1,-0.2){$x$}
\multiput(0,0)(1,0){5}{\line(0,1){0.3}}
\put(-0.2,-0.3){\tabular[t]{c}a\\b\\c\endtabular}
\put(0.75,-0.3){\tabular[t]{c}d\\e\\f\endtabular}
\put(1.8,-0.3){\tabular[t]{c}g\\h\\i\endtabular}
\put(2.8,-0.3){\tabular[t]{c}j\\k\\l\endtabular}
\put(3.7,-0.3){\tabular[t]{c}m\\n\\o\endtabular}
\end{picture}

\end{document}


Using TikZ will probably be the best approach. Here is a sample solution to your request. I did comment out the code to make it easier to understand.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
% Horizontal line
\draw[->] (0,0) -- (4.5,0)node[xshift = 0.25cm]{$x$};
\def\ourInfo{{
{"a", "d", "g", "j", "m"},  % Row 0
{"b", "e", "h", "k", "n"},  % Row 1
{"c", "f", "i", "l", "o"}   % Row 2
}}
% getting information from the 2D array
\foreach \i in {0,...,2}{%rows
\foreach \j in {0, ..., 4}{%columns
% The \pgfmathparse gets what is inside the cell at (i,j).
% \pgfmathresult will output the result obtained previously.
\draw[] (\j,-0.5-\i/2)node[]{\pgfmathparse{\ourInfo[\i][\j]}\pgfmathresult};
}
}
% Taking care of the numbers above the horizontal line.
\foreach \i in {0, ..., 4}{
\draw(\i,0) -- (\i,0.25)node[yshift = 0.25cm]{\i};
}
% Define a 1D array and use a foreach loop to place what it has.
\def\innerData{{"", "abc", "xyz", "uvw"}}
\foreach \i in {0, ..., 3}{
\draw(\i+0.5,0) node[yshift = 0.5cm]{\pgfmathparse{\innerData[\i]}\small\pgfmathresult};
}
\end{tikzpicture}
\end{document}


I'd recommend TikZ as it has means to change all aspects of the appearance (arrow heads, line widths, line style, color, opacity) and has \foreach loops that help avoiding repetition and works with all standard compilers.

\documentclass[tikz,border=3.14mm]{standalone}
\newcounter{pft}
\begin{document}
\begin{tikzpicture}
\draw[-stealth] (0,0) -- (5,0);
\draw foreach \X in {0,...,4} {(\X,0) -- ++ (0,0.2) node[above]{\X} };
\foreach \X in {0,...,14}
{\stepcounter{pft}
\node at ({int(\X/3)},{-0.45*(1+mod(\X,3))}) {\alph{pft}};}
\foreach \X [count=\Z] in {abc,xyz,uvw}
{\node[text depth=0.5ex] at (1.5+\Z,0.45){\X};}
\end{tikzpicture}
\end{document}