Pgfplots-Boxplot: Ausreißerstil ändern

Pgfplots-Boxplot: Ausreißerstil ändern

Ich versuche, mehrere Boxplots zu zeichnen (Daten aus Datei gelesen) und möchte, dass sie gleich aussehen. Das ist mir für alles gelungen, außer für die Ausreißer, die immer noch den Standardstil/die Standardfarbkarte verwenden (siehe Abbildung unten).

Wie kann ich ihr Aussehen ändern?

Bildbeschreibung hier eingeben

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}

Antwort1

Es gibt viele Möglichkeiten, das Gewünschte zu erreichen. Eine Möglichkeit besteht darin, einen benutzerdefinierten Stil zu erstellen und ihm alle Optionen/Schlüssel hinzuzufügen.

% 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}

Bild, das das Ergebnis des obigen Codes zeigt

verwandte Informationen