# pgfplots: How do I manually change xtick labels (a letter instead of a number)?

The below picture is what I have currently: what I want is to change 4 to a and 6 to b; but, if I change one of them using the xticklabel option it globally changes all x-values to that value. There's also the issue of the xtick height; if you see below, it goes way above the normal distribution--I tried some of the options in the "Tick-Fine Tuning" section in the manual, but they didn't work for me. I'm also trying to remove the y-axis: one thing I tried is messing around with the axis lines*=left option; however I wasn't able to come up with the result I wanted.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}

\begin{tikzpicture}
\begin{axis}[
no markers, domain=0:10, samples=100,
axis lines*=left,
every axis y label/.style={at=(current axis.above origin),anchor=south},
every axis x label/.style={at=(current axis.right of origin),anchor=west},
height=3cm, width=6cm,
xtick={4, 6}, ytick=\empty,
enlargelimits=false, clip=false, axis on top,
grid = major
]
\addplot [fill=cyan!20, draw=none, domain=4:6] {gauss(5,1)} \closedcycle;

\end{axis}

\end{tikzpicture}
\end{document}


Furthermore, I would also like to have another normal distribution in the same row: I don't know how to go about doing that.

• Please limit your posts to one question per post, I provide an answer to the question about changing the x tick label from 4 to a etc. Apr 27 at 2:22
• Thanks for the good MWE (but you can remove several of the options for the question). Apr 27 at 2:28
• About removing the y axis, there are several related question, see tex.stackexchange.com/questions/296325 (axis y line=none) for example (I googled pgfplots remove y axis). Apr 27 at 2:39
• I also removed for normal distribution from your title because it is irrelevant to the question. Apr 27 at 2:41
• Thank you for the help that related question solved the y-axis removal for me. @Dr.ManuelKuehner Apr 27 at 2:48

• Using xticklabels = {\strut a, \strut b}, leads to the following output (see also the two comments in the code). You can use $a$ instead of a if that is more appropriate for your use case.
• You have to be careful, there is an option called xticklabel and another one called xticklabels (with "s").
• This caused confusion for myself in the past :).

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18} % <-- ADDED, see Warning Message "Package pgfplots Warning: running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing \pgfplotsset{compat=1.18} into your preamble."
\begin{document}

\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}

\begin{tikzpicture}
\begin{axis}[
no markers,
domain=0:10,
samples=100,
axis lines*=left,
every axis y label/.style={at=(current axis.above origin),anchor=south},
every axis x label/.style={at=(current axis.right of origin),anchor=west},
height=3cm,
width=6cm,
xtick={4, 6},
xticklabels = {\strut a, \strut b}, % <-- ADDED, the \strut makes that both labels have the same height
ytick=\empty,
enlargelimits=false,
clip=false,
axis on top,
grid = major,
]
\addplot [fill=cyan!20, draw=none, domain=4:6] {gauss(5,1)} \closedcycle;