使用 pgf / tikz 可以轻松对条形图进行分组,例如,
\begin{tikzpicture}
\begin{axis}[
width = 0.85*\textwidth,
height = 4cm,
major x tick style = transparent,
xbar=2*\pgflinewidth,
bar width=6pt,
xmajorgrids = true,
xlabel = {Run time speed},
symbolic y coords={A,B},
ytick = data,
scaled x ticks = false,
enlarge y limits=0.2,
xmin=0,
legend cell align=right,
legend style={
at={(1,1.05)},
anchor=south east,
column sep=1ex
}
]
\addplot[style={ppurple,fill=ppurple,mark=none}]
coordinates {(0.62103,A) (0.76326,B)};
\addplot[style={ggreen,fill=ggreen,mark=none}]
coordinates {(0.84163,A) (0.96132,B)};
\legend{No vectorization,TreeScore $>2$,TreeScore $>3$,TreeScore $>4$}
\end{axis}
\end{tikzpicture}
产生如下图所示的结果:
但是,是否可以使用箱线图/晶须图代替条形图来做同样的事情?
我的起始代码是这样的:
\begin{tikzpicture}
\begin{axis}
[
width = 0.85*\textwidth,
height = 12cm,
major x tick style = transparent,
xbar=2*\pgflinewidth,
ytick={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},
yticklabels={A,B},
]
\addplot+[style={ppurple,fill=ppurple,mark=none,fill opacity=0.2},
boxplot prepared={
median=0.8227,
upper quartile=0.8873,
lower quartile=0.4659,
upper whisker=0.9134,
lower whisker=0.3202
},
] coordinates {};
\addplot+[style={ggreen,fill=ggreen,mark=none,fill opacity=0.2},
boxplot prepared={
median=0.8286, upper quartile=0.94934, lower quartile=0.64128, upper whisker=0.96482, lower whisker=0.56093
},
] coordinates {};
\end{axis}
\end{tikzpicture}
...但我不知道如何对这两个图进行分组,以便它们都属于组 A。使用符号 y 坐标似乎不起作用。