DominikPeters / tikz.dev-issues

Feedback, suggestions, and bug reports for tikz.dev
1 stars 0 forks source link

pgfplots: The second Bar plots example needs `\usetikzlibrary{patterns}` #28

Closed muzimuzhi closed 7 months ago

muzimuzhi commented 7 months ago

Describe the bug

The second example in section "Bar Plots" looks different than that in PDF, sec. 4.5.4 "Bar Plots".

Current link: https://tikz.dev/pgfplots/reference-2dplots#sec-16.4. This link will change when #27 is solved.

Screenshots

Analysis

Compile this example raises an error

! Package tikz Error: You need to say \usetikzlibrary{patterns}.

Adding that library solves the problem.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}

\usetikzlibrary{patterns}

\begin{document}
% Preamble: \pgfplotsset{width=7cm,compat=1.18}
\begin{tikzpicture}
\begin{axis}[xbar,enlargelimits=0.15]
    \addplot [draw=blue,
        pattern=horizontal lines light blue,
    ] coordinates {
        (10,5) (15,10) (5,15) (24,20) (30,25)
    };
    \addplot [draw=black,
        pattern=horizontal lines dark blue,
    ] coordinates {
        (3,5) (5,10) (15,15) (20,20) (35,25)
    };
\end{axis}
\end{tikzpicture}
\end{document}
muzimuzhi commented 7 months ago

Thank you for such a quick fix!