使用统计库摆弄箱线图

使用统计库摆弄箱线图

对于任何有统计软件包经验的人,请给我一些关于如何实现以下目标的提示:1. 用灰色在框中阴影!30 2. 将整个箱线图向上移动 0.25 个单位,使其不要太靠近轴。

这是我得到的输出:

电流输出

这是我目前拥有的代码:

\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}

谢谢你!

答案1

这似乎有效。

\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}

在此处输入图片描述

相关内容