I want to implement the top answer in this to colour and hatch bars as above, and compiled exactly the same code.
\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar, samples=10, enlarge y limits=upper, ymin=0]
\addplot +[
black,
fill=yellow,
postaction={
pattern=north east lines
}
]{rnd};
\end{axis}
\end{tikzpicture}
\end{document}
However, I got this. Only the bottom was hatched.
I also tried every path from the same answer.
\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{patterns}
\makeatletter
\tikzset{nomorepostaction/.code=\let\tikz@postactions\pgfutil@empty}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar, samples=10]
\addplot +[
black,
fill=yellow,
every path/.style={
postaction={
nomorepostaction,
pattern=north east lines
}
}
]{rnd};
\end{axis}
\end{tikzpicture}
\end{document}
Now, the bottom is gone.
How can I get the same result as the original article? Since the source code is exactly the same, I suspect this is to do with my latex version, which is as below.
$ pdflatex --version
pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2021)
kpathsea version 6.3.3
Copyright 2021 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03



