align xticks in PGFPlots

Simply add typeset ticklabels with strut to the axis (or groupplots) options to get the desired result.

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin=0.5,
        xmax=3.5,
        ymin=2.43,
        ymax=3.05,
        xtick={1,2,3},
        xticklabels={zero, low , high},
        % ---------------------------------------------------------------------
        % added
        typeset ticklabels with strut,
        % ---------------------------------------------------------------------
        % (for debugging purposes only)
        xticklabel style={
            name=tick no \ticknum,
        },
        % ---------------------------------------------------------------------
    ]
    \end{axis}
        % ---------------------------------------------------------------------
        % (for debugging purposes only)
        \draw [red] (tick no 0.base) -- (tick no 2.base);
        % ---------------------------------------------------------------------
\end{tikzpicture}
\end{document}

image showing a zoomed part of the above code


Just add a \vphantom{l} next to "zero" (it is lowercase L) to create this vertical "offset":

\documentclass[class=scrartcl,14pt]{standalone}
%\usepackage{fontspec}
%\usepackage{luatex85}
%\usepackage{unicode-math}
\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}
\usepackage{calc}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{groupplot}[group style={group size=1 by 1, horizontal sep=2cm,
xlabels at=edge bottom
},
%~ yticklabel style={/pgf/number format/fixed},
%~ xticklabel style={/pgf/number format/fixed},
scaled y ticks = false,
scaled x ticks = false,
xtick pos=left,
ytick pos=left,
%xlabel=time (week)
]
\nextgroupplot[xmin=0.5,xmax=3.5,xtick={1,2,3},ymin=2.43,ymax=3.05,xticklabels={{\vphantom{l}zero}, low , high},
xlabel={label}]

\end{groupplot}

\end{tikzpicture}
\end{document}

enter image description here

Tags:

Pgfplots