2

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:

current output

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
]
\addplot[
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!

1 Answer 1

3

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
]
\addplot[yshift=0.25cm,% <- move up
/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}

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .