以下代码中有两个问题。我想将框放在行的中间,并希望显示最大值。任何建议都将不胜感激。谢谢。
\documentclass{report}
\usepackage{pgf,pgfplots}
\usetikzlibrary{fit,calc}
\usepgfplotslibrary{external}
\newcommand{\boxplot}[6]{%#max %no change
%#1: center, #2: median, #3: 1/4 quartile, #4: 3/4 quartile, #5: min, #6: max
\filldraw[fill=gray!25,line width=0.2mm] let \n{boxxl}={#1-0.4}, \n{boxxr}={#1+0.4} in (axis cs:\n{boxxl},#3) rectangle (axis cs:\n{boxxr},#4);
% draw the box
\draw[line width=0.2mm, color=orange] let \n{boxxl}={#1-0.1}, \n{boxxr}={#1+0.1} in (axis cs:\n{boxxl},#2) -- (axis cs:\n{boxxr},#2);
% median
\draw[line width=0.2mm,color=blue] (axis cs:#1,#4) -- (axis cs:#1,#6);
% bar up
\draw[line width=0.9mm,color=pink] let \n{whiskerl}={#1-0.025}, \n{whiskerr}={#1+0.025} in (axis cs:\n{whiskerl},#6) -- (axis cs:\n{whiskerr},#6); % upper quartile
\draw[line width=0.2mm,color=black] (axis cs:#1,#3) -- (axis cs:#1,#5);
% bar down
\draw[line width=0.6mm,color=yellow] let \n{whiskerl}={#1-0.025}, \n{whiskerr}={#1+0.025} in (axis cs:\n{whiskerl},#5) -- (axis cs:\n{whiskerr},#5); % lower quartile
}
\begin{document}
\tikzset{external/remake next}
\begin{tikzpicture}
\begin{axis}[
xmin=0.5, xmax=6, %x level interval
ymin=1, ymax=100, % y level interval
xtick={1,2,3,4,5}, % X level name if not xtick level activate
xticklabels={Foo,20,Bar,SVM, DTree} % X level name
]
%#1: center, #2: median, #3: 1/4 quartile, #4: 3/4 quartile, #5: min, #6: max
\boxplot{1}{8.5}{55}{69}{20}{35}
\boxplot{2}{38.5}{55}{59}{40}{35}
\boxplot{3}{8.5}{55}{29}{20}{35}
\boxplot{4}{8.5}{55}{59}{20}{35}
\boxplot{5}{8.5}{55}{89}{20}{35}
\end{axis}
\end{tikzpicture}
\end{document}
代码图片