Differences
This shows you the differences between two versions of the page.
— | latex:tikz:boxplot [2020/06/10 21:43] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | How to make nice boxplots with whiskers (if plotting with [[http:// | ||
+ | <code latex> | ||
+ | \documentclass{report} | ||
+ | \usepackage{pgf, | ||
+ | \usetikzlibrary{fit, | ||
+ | \usepgfplotslibrary{external} | ||
+ | \newcommand{\boxplot}[6]{% | ||
+ | %#1: center, #2: median, #3: 1/4 quartile, #4: 3/4 quartile, #5: min, #6: max | ||
+ | \filldraw[fill=white, | ||
+ | \draw[line width=0.2mm, | ||
+ | \draw[line width=0.2mm] (axis cs:#1,#4) -- (axis cs:# | ||
+ | \draw[line width=0.2mm] let \n{whiskerl}={# | ||
+ | \draw[line width=0.2mm] (axis cs:#1,#3) -- (axis cs:# | ||
+ | \draw[line width=0.2mm] let \n{whiskerl}={# | ||
+ | } | ||
+ | \begin{document} | ||
+ | |||
+ | \tikzset{external/ | ||
+ | \begin{tikzpicture} | ||
+ | \begin{axis}[xmin=0, | ||
+ | xtick={1, | ||
+ | %#1: center, #2: median, #3: 1/4 quartile, #4: 3/4 quartile, #5: min, #6: max | ||
+ | \boxplot{1}{.00479}{.001777}{.011400}{0.0000232}{.0209} | ||
+ | \boxplot{2}{.00828}{.004987}{.018975}{0.0005100}{.1} | ||
+ | \boxplot{3}{.03300}{.013950}{.088550}{0.0008580}{1.06} | ||
+ | \boxplot{4}{.06708}{.034778}{.135850}{0.0060770}{5.08} | ||
+ | \boxplot{5}{.06800}{.033600}{.152500}{0.0000030}{1.51} | ||
+ | \end{axis} | ||
+ | \end{tikzpicture} | ||
+ | \end{document} | ||
+ | </ | ||
+ | adapted from " |