你能告诉我如何添加孵化到箱形图在TikZ
?提前致谢。
\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
boxplot/draw direction=y,
ylabel={Time (minutes)},
height=6cm,
width=6cm,
ymin=0,ymax=11,
cycle list={{black},{red}},
xtick={1,2},
xticklabels={Phase 1, Phase 2},
]
\addplot+[
fill,fill opacity=0.2,
boxplot prepared={
median=2.59,
upper quartile=3.35,
lower quartile=2,
upper whisker=4.4,
lower whisker=1.1
},
] coordinates {};
\addplot+[
fill,fill opacity=0.2,
boxplot prepared={
median=6.57,
upper quartile=7.93,
lower quartile=5.93,
upper whisker=10.68,
lower whisker=4.03
},
] coordinates {};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
解决方案是根据新手册在里面添加哈希模式描述,\addplot+[...]
如下所示:
\addplot+[
pattern={north east lines},pattern color=black,
boxplot prepared={
median=2.59,
upper quartile=3.35,
lower quartile=2,
upper whisker=4.4,
lower whisker=1.1
},
] coordinates {};