Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
Add \usetikzlibrary{pgfplots.statistics} to your preamble. –  Ignasi Feb 19 at 20:09
    
@Ignasi Thank you, I try –  HAL9000 Feb 19 at 20:33
    
@Ignasi good, it works. Actually the manual reported it but it was not very clear, in my opinion. –  HAL9000 Feb 19 at 20:38

1 Answer 1

up vote 4 down vote accepted

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.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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