# Fiddling with Box plot using statistics library

For anyone who is experienced with the statistics package please give me some tips on how to achieve the following: 1. shaded in the box with gray!30 2. move the whole boxplot up by 0.25 unit so it is not too close to the axis.

This is the output I get:

and this is the code I have so far:

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{wallpaper}
\usetikzlibrary{shapes.geometric}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{statistics}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
axis lines=middle,
xmajorticks=true,
ytick=\empty,
xtick=\empty,
xmin=500,
xmax=8000,
%xtick={1000,3000,4000,5000,6000,7000,8000},
xtick={1000,2000,3000,4000,5000,6000,7000,8000},
%axis x line=bottom,
axis line style={-},
axis y line=none,
enlargelimits=0.05,
height=3.2cm,
width=17cm,
clip=false
]
opacity=100,
boxplot prepared={
median=5750,
upper quartile=6500,
lower whisker=500,
lower quartile=4500,
upper whisker=8000,
whisker extend=0 % height of whiskers
},black
] coordinates {};
%
\end{axis}
\end{tikzpicture}

\end{document}


Thank you!

This seems to work.

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
axis lines=middle,
xmajorticks=true,
ytick=\empty,
xtick=\empty,
xmin=500,
xmax=8000,
%xtick={1000,3000,4000,5000,6000,7000,8000},
xtick={1000,2000,3000,4000,5000,6000,7000,8000},
%axis x line=bottom,
axis line style={-},
axis y line=none,
enlargelimits=0.05,
height=3.2cm,
width=17cm,
clip=false
]
/tikz/fill=gray!25,% <- fill
boxplot prepared={
median=5750,
upper quartile=6500,
lower whisker=500,
lower quartile=4500,
upper whisker=8000,
whisker extend=0 % height of whiskers
},
] coordinates {};
%
\end{axis}
\end{tikzpicture}

\end{document}


• This is perfect. Thanks @mamort! :) Jun 1, 2019 at 4:56