Pgfplots 상자 그림: 이상값 스타일 변경

Pgfplots 상자 그림: 이상값 스타일 변경

나는 여러 개의 상자 그림(파일에서 읽은 데이터)을 플롯하려고 하는데 그것들이 동일하게 보이길 원합니다. 나는 여전히 기본 스타일/색상 맵을 사용하는 이상값을 제외한 모든 항목에 대해 이를 수행했습니다(아래 그림 참조).

어떻게 모양을 바꿀 수 있나요?

여기에 이미지 설명을 입력하세요

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

원하는 것을 달성하는 방법에는 여러 가지가 있습니다. 한 가지 방법은 사용자 정의 스타일을 만들고 여기에 모든 옵션/키를 추가하는 것입니다.

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

위 코드의 결과를 보여주는 이미지

관련 정보