1

I am trying to plot several box plots (data read from file), and I want them to look the same. I managed to do that for everything but the outliers, that still use the default style/colormap (see the picture below).

How can I change their appearance?

enter image description here

MWE

\documentclass{minimal}
\usepackage{pgfplots}
\usepgfplotslibrary{statistics}

\begin{document}

   \begin{tikzpicture}
   \begin{axis}[y=1cm]
      \foreach \n in {1,...,8}
      {
      \addplot+ [boxplot,draw=black,solid,fill=white] table [row sep=\\,y index=0] 
         {
         data\\
         1\\ 2\\ 1\\ 5\\ 20\\ 10\\
         7\\ 10\\ 9\\ 8\\ 9\\ 9\\
         };
      }
   \end{axis}
   \end{tikzpicture}
\end{document}

1 Answer 1

2

There are plenty ways of achieving what you want. One way is to create a custom style and add all options/keys to it.

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{statistics}
    \pgfplotsset{
        compat=1.3,
        % create a custom style for the boxplots
        my boxplot style/.style={
            boxplot,
            draw=black,
            solid,
            fill=white,
            % -------------------------------------------------------------
            % add your desired mark symbol and mark style here
            mark=*,
            every mark/.append style={
                fill=gray,
            },
            % -------------------------------------------------------------
        },
    }
\begin{document}
\begin{tikzpicture}
   \begin{axis}
        \foreach \n in {1,...,8} {
            \addplot+ [
                % apply the custom style
                my boxplot style,
            ] table [row sep=\\,y index=0] {
                data\\
                1\\ 2\\ 1\\ 5\\ 20\\ 10\\
                7\\ 10\\ 9\\ 8\\ 9\\ 9\\
            };
        }
   \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code

0

You must log in to answer this question.

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