2

I'm making some boxplots with the pgf statistics library. And I found the following.

This:

\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}


\usepgfplotslibrary{statistics}
\usepgfplotslibrary{fillbetween}

%Loading the libraries the other way around gives the same result
%\usepgfplotslibrary{fillbetween}
%\usepgfplotslibrary{statistics}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        boxplot/draw direction = y,
    ]
        \addplot [boxplot] table [col sep=comma,y index=0] {datatest.txt};
    \end{axis}
\end{tikzpicture}
\end{document}

produces this: enter image description here

But this (I'm now including fillbetween and statistics in the same \usepgfplotslibrary command):

\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\usepgfplotslibrary{fillbetween,statistics}

%Loading the libraries the other way around gives the same result
%\usepgfplotslibrary{statistics,fillbetween}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        boxplot/draw direction = y,
    ]
        \addplot [boxplot] table [col sep=comma,y index=0] {datatest.txt};
    \end{axis}
\end{tikzpicture}
\end{document}

produces this:

enter image description here Where the outlier is not marked.

Why does loading two libraries in the same statement break one? Thx for the help ;-)

edit, sorry I forgot the test file:

datatest.txt:

1
1
2
1
1
3
5

I also did test this both with \usepgfplotslibrary{statistics,fillbetween} and \usepgfplotslibrary{fillbetween,statistics} both produce the wrong result. At the same time, both

\usepgfplotslibrary{statistics} 
\usepgfplotslibrary{fillbetween}

and

\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{statistics} 

produce the right result.

3
  • what is in the datatest.txt? – Ulrike Fischer Oct 29 '20 at 14:23
  • btw: the problem is quite probably the order how you load the libraries, but without a test file it is difficult to test. – Ulrike Fischer Oct 29 '20 at 14:53
  • @UlrikeFischer, I'm really sorry I forgot the datafile, it's there now ;-) I did test with loading the libraries in both orders (both with them in the same command and in seperate commands), the result was the same – Thorbjørn E. K. Christensen Oct 29 '20 at 15:39
3

The definition \use@@pgfplotslibrary has at the end this piece of code

    \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax
    \else
        \expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfp@library@\pgf@temp @loadoptions\endcsname
        \expandafter\pgfplotsset\expandafter{\pgfplots@glob@TMPa}%
    \fi

Its purpose is to load "library hook code". In the case of the statistic library it should execute \csname pgfp@library@statistics@loadoptions\endcsname which basically does

/pgfplots/compat/library hook={statistics}{/pgfplots/boxplot/estimator=Excel,/pgfplots/boxplot/ensure mark=true},

where the ensure mark=true gives your mark.

The problem is that #1 is statistics,fillbetween or fillbetween,statistics if you combine both in one command, and so the test is always false.

So it is a bug but simply replacing #1 by \pgf@temp does not work, as these library calls can be nested and so the value is not correct in all cases.

1
  • So this means that any pgfplotslibrary that needs a hook would fail if you load them at once? this seems like a fairly big problem, but I see that it's already been reported, thanks for the help 8-) – Thorbjørn E. K. Christensen Oct 29 '20 at 20:54
2

I do not have the reputation to comment. So I am writing an "answer". The difference is that different files get loaded. When you say

\usepgfplotslibrary{fillbetween,statistics}

you load

/usr/local/texlive/2020/texmf-dist/tex/generic/pgfplots/pgfcontrib/tikzlibraryfillbetween.code.tex

whereas with

\usepgfplotslibrary{statistics}
\usepgfplotslibrary{fillbetween}

you load

/usr/local/texlive/2020/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex

All the paths refer to my TeXLive installation, but the exact names of the paths do not matter.

As far as I can see this has to do with \pgfplots@iffileexists, which gets called by \use@@pgfplotslibrary. It appears that you are in a "wrong" subdirectory when this check is performed.

So IMHO the bottomline is that you have found an issue, which you may want to report on this site.

1
  • Thanks for the help, I think Ulrikes answer was a better explanation of the phenomenon, but seeing this, as a more practical example, was also nice ;-) – Thorbjørn E. K. Christensen Oct 29 '20 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.