# Drawing multiple box plots from a file

I've got data in the following format

n lw lq m uq uw
50 200 209 237 327 569
100 376 379 386 390 391
150 ...
...


Where lw = lower whisker, lq = lower quartile, etc.

I want to plot each box against n on the x axis and end up with a figure that looks something like this:

http://www.togaware.com/datamining/survivor/rplot-boxplot-by-month.png

I've been trying to modify an existing graph that was plotting the non-boxed data, but I can't find a way to configure it that doesn't result in LaTeX failing to compile.

\pgfplotstableread{code/tree/results.dat}\loadedtable

\begin{figure}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
xlabel near ticks,
ylabel near ticks,
xlabel={Size of Tree $n$},
ylabel={Time $\mu$s},
width=11cm,
height=10cm
]
\addplot [box plot] table[x=n,y=???] from \loadedtable;
\end{tikzpicture}
\caption{Test Results}
\label{fig:tree-results-1}
\end{figure}


How can I specify the box plot limits using a data file rather than a prepared set of fixed values?

• Welcome to TeX.SX!! It is better to post a full minimal working example. For example, A LaTeX MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. Unless the problem is a compilation error, the code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will! – Andrew May 6 '16 at 14:45
• Thanks, that's helpful to know. However, in this case, my existing code/environment is pretty much irrelevant, rather I'm just looking for a canonical example, rather than asking for a fix. – Dan Prince May 6 '16 at 14:58
• You are asking people to plot limits from a data file. A MWE will give people something to work with rather than asking the to write everything from scratch for you. It saves people time and, as I said, makes it much more likely that some one will help you. – Andrew May 6 '16 at 21:46
• Ok, I understand. Let me clarify then, what should my minimum working example show? I don't understand how to draw a box plot from a file. I could include a MWE of a scatter graph, but I don't see how that would help anyone. – Dan Prince May 6 '16 at 21:52
• It seems the boxplot was not intended to interface with pgfplotstable. It looks like you are going to need a foreach loop and a whole lot of \pgfplotstablegetelem calls. – John Kormylo May 7 '16 at 3:48