1

I'm looking to add boxplots to my document. I know there are already working examples out there, including on this site, but I was curious if I could get the bare minimum simplest example to run. The plots I actually want to add shouldn't even be too much more complicated; I'll just need to put multiple boxes and whiskers alongside each other, and possibly resize if the plot turns out too large.

Here's what I have now:

\documentclass[11pt]{amsart}

\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{statistics}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot [boxplot]
{1,2,3,4,5};
\end{axis}
\end{tikzpicture}

\end{document}

I get an error on the line after \end{tikzpicture} saying: Paragraph ended before \pgfflt@readlowlevelfloat was complete.

I'm curious what this error means, and what's missing from the code.

Edit: Quoting directly from the pgfplots manual page 505:

Data points can be given by means of any supported input stream, although the most useful ones are probably \addplot table and \addplot coordinates.

This makes me curious what all of the supported input streams are, and why a simple listing wasn't included as one of them.

Anyway, I tried the two listed in this quote. Replacing the line {1,2,3,4,5}; with

coordinates {(1),(2),(3),(4),(5)};

or

coordinates {(1,1),(2,2),(3,3),(4,4),(5,5)};

(just in case coordinates must have length at least 2)

yields the error message: Sorry, I could not read the plot coordinates near ',(3),(4),(5)' for the first, and similarly for the second. What is wrong with those lines?

On the other hand, replacing it with

table [row sep=\\,y index=0] {data\\ 1\\ 2\\ 3\\ 4\\ 5};

yields the error message: File ended while scanning use of \pgfplotstableread@loop@next. So something is still wrong here? I'm also curious about row sep=\\ and y index=0; it seems removing either leads to a different error.

7
  • Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. Aug 15, 2022 at 12:21
  • 2
    Welcome to TeX.SX! Apart fom adding a document class as well as \begin{document} and \end{document}, you need to feed \addplot with something it can parse, such as a function, a table or a set of cooridates. This list of integers does not seem to be a format which can be parsed by PGF. Maybe have a look at the manual? Aug 15, 2022 at 12:24
  • @JasperHabicht Sorry for the slow reply. Could you clarify what exactly qualifies as "something it can parse"? I saw the manual before, and while its too long to read in full, I read page 505. It says the input should be a one-dimensional sample, and gives an example, but doesn't clearly say that the syntax needs to be like the example. Plus I'm curious what \pgfflt@readlowlevelfloat means.
    – J.D.
    Aug 17, 2022 at 1:42
  • 1
    The manual has quite a lot of examples. It shows that you can use \addplot [boxplot] table [row sep=\\, y index=0] { data \\ 1 \\ 2 \\ 3 \\ 4 \\ 5 \\ };. You don't need to read all of the manual, just the parts you need. As for \pgfflt@readlowlevelfloat, it is an internal helper macro for PGFs handling of floating numbers. You can read more about this in the PGF manual in chapter 56, but it is really not that important to understand this. Aug 17, 2022 at 6:37
  • @JasperHabicht Hello, I updated my question a couple days ago. May I ask why these lines with coordinates and table don't work? Thanks
    – J.D.
    Aug 22, 2022 at 2:22

1 Answer 1

2

The input must be given in the format specified for different plot types in the manual. You can not expect PGFPlots, TikZ or any other programming language to guess what you mean. Here is a working eaxmple:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {(1,1) (2,2) (3,3) (4,4) (5,5)};
\end{axis}
\end{tikzpicture}
\end{document}

More examples are give in the manual p. 41:

4.3 The \addplot Command: Coordinate Input

If you need a strict definition of the format, it can be found in the manual p. 46:

4.3.1 Coordinate Lists

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .