# Pgfplots: Alphanumeric x tick label

I have some data that needs to be plotted against time. But the time is not absolute (NOT 0,1,2,3,...). So I want to represent x tick label as relative labels (like t, t+1, t+2, t+3, ...). My data set is large (around a million data points), So I cannot write it down manually for each data point as given in this community for some questions (example 1,example 2)

How can I achieve this goal?

You could use something like

xticklabel={
\ifnum \ticknum=1 $t$
\else
\pgfmathparse{\ticknum-1} $t+\pgfmathprintnumber[fixed,precision=0]{\pgfmathresult}$
\fi
}


Example:

\documentclass[margin=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,
xticklabel={
\ifnum \ticknum=1 $t$
\else
\pgfmathparse{\ticknum-1} $t+\pgfmathprintnumber[fixed,precision=0]{\pgfmathresult}$
\fi
}
]
\end{axis}
\end{tikzpicture}
\end{document}


Or you can use the suggestion by @Alenanno (see the comment below)

xticklabel={
\ifnum \ticknum=1 $t$
\else
\pgfmathtruncatemacro\myticknum{\ticknum-1} $t+\myticknum$
\fi
}

• I think this might work too: \pgfmathtruncatemacro\mytick{\ticknum-1} $t+\mytick$ – Alenanno Jun 2 '16 at 13:36
• @Alenanno Thanks for the hint. This is shorter and works too. – esdd Jun 2 '16 at 13:54