6

The text xticks are not placed on the same line, rather the same height counting from the highest letter (zero is much higher than high and low).

enter image description here

How can you fix this?

MWE:

\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={zero, low , high},
xlabel={label}]

\end{groupplot}

\end{tikzpicture}

\end{document}
8

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

| improve this answer | |
  • Maybe it would be a good idea to make this the default? – Marijn Apr 4 '18 at 9:56
  • Feel free to file a feature request in the PGFPlots Tracker. – Stefan Pinnow Apr 4 '18 at 11:33
2

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.