7

I was trying to reproduce an example saw in the manual of PGFPLOTS v1.9:

\documentclass[11pt,a4paper,twoside,openright]{report}

\usepackage{tikz}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{array} 
\usepackage{verbatim}
\usepackage{caption}
\usepackage{epstopdf}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{tcolorbox}

\usepackage{pgfplots}

\pgfplotsset{compat=1.9}

\begin{document}
 \begin{tikzpicture}
\begin{axis}[y=1cm]
\addplot+[
boxplot prepared={
lower whisker=42, lower quartile=45,
median=47,
upper quartile=47.5, upper whisker=48,
draw relative anchor=0.5, }, ]
table[row sep=\\,y index=0] { 40\\ 34\\ 56\\ };
\end{axis}
\end{tikzpicture}
\end{document}

However I'm getting the following error:

Package pgfkeys Error: I do not know the key '/tikz/boxplot prepared' 

I updated texlive today and my log says

Package: tikz 2010/10/13 v2.10

Is the code too old for my version?

  • 2
    Add \usetikzlibrary{pgfplots.statistics} to your preamble. – Ignasi Feb 19 '14 at 20:09
  • @Ignasi good, it works. Actually the manual reported it but it was not very clear, in my opinion. – HAL9000 Feb 19 '14 at 20:38
8

Box Plots is a subsection of Statistics section in pgfplots documentation. Therefore you need to include

\usetikzlibrary{pgfplots.statistics}

to your preamble to draw Box Plots or Histograms.

Not related with your question but your preamble:

  • includes \usepackage{caption} twice.
  • includes \usepackage{tikz} which is already loaded by pgfplots.
  • tikz, tcolorbox and pgfplots load xcolor which provides more facilities than color.

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.