pgfplots의 여러 삼항 플롯 및 원형 차트

pgfplots의 여러 삼항 플롯 및 원형 차트

저는 많은 삼항 도표와 원형 차트를 그리려고 합니다. 이상적으로는 다음과 같이 보여야 합니다. 여기에 이미지 설명을 입력하세요 여기에 이미지 설명을 입력하세요

왼쪽의 파이 차트(삼원 플롯)는 현재 상황에 대한 설명 역할을 하는 반면, 오른쪽에는 데이터가 포함된 실제 플롯이 있습니다. 72개의 벤치마크에 대해 원형 차트(3항 플롯)를 그려야 하므로 총 72개의 원형 차트와 72개의 3항 플롯이 됩니다. 내가 사용하고 있는 현재 접근 방식에는 많은 코드 중복과 수동 조정이 필요합니다. 좀 더 스마트하게 정리하는 방법은 없을까요? 그룹롯과 비슷합니까? 게다가 pgfplots에 대한 지식이 거의 없기 때문에 코드를 다듬는 데 많은 시간이 필요합니다. 특히 원형 차트 제목의 글꼴 크기를 변경하는 방법과 삼항 도표에서 제목을 차트에 더 가깝게 이동하는 방법을 전혀 모릅니다. MWE는 다음과 같습니다.

\documentclass{article}
\usepackage{pgfplots, pgfplotstable}
\usepgfplotslibrary{ternary, units}
\usepackage{tikz}
\begin{document}
\newcommand{\legend}[2][]{
 \begin{scope}[#1]
 \path
    \foreach \n/\s in {#2}
        {
              ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
        }
;
\end{scope}
}
\tikzstyle{chart}=[
legend label/.style={font={\scriptsize},anchor=west,align=left},
legend box/.style={rectangle, draw, minimum size=5pt},
axis/.style={black,semithick,->},
axis label/.style={anchor=east,font={\tiny}},
]
\tikzstyle{pie chart}=[
chart,
slice/.style={line cap=round, line join=round, very thick,draw=white},
pie title/.style={font={\bf}},
slice type/.style 2 args={
    ##1/.style={fill=##2},
    values of ##1/.style={}
}
]
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcommand{\pie}[3][]{
\begin{scope}[#1]
\pgfmathsetmacro{\curA}{90}
\pgfmathsetmacro{\r}{1}
\def\c{(0,0)}
\node[pie title] at (90:1.3) {#2};
\foreach \v/\s in{#3}{
    \pgfmathsetmacro{\deltaA}{\v/100*360}
    \pgfmathsetmacro{\nextA}{\curA + \deltaA}
    \pgfmathsetmacro{\midA}{(\curA+\nextA)/2}

    \path[slice,\s] \c
        -- +(\curA:\r)
        arc (\curA:\nextA:\r)
        -- cycle;
    \pgfmathsetmacro{\d}{max((\deltaA * -(.4/50) + 1) , .5)}

    \begin{pgfonlayer}{foreground}
    \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r);
    \end{pgfonlayer}

    \global\let\curA\nextA
}
\end{scope}
}
\begin{figure}
\begin{minipage}{0.3\linewidth}
\begin{tikzpicture}
[
pie chart,
slice type={inlined}{lightgray},
slice type={noninlined}{darkgray},
pie values/.style={font={\tiny}},
scale=1.5
]
\pie{benchmark}{41/inlined,13/noninlined}
\legend[shift={(-1cm,-1cm)}]{{Inlined}/inlined, {Not inlined}/noninlined}

\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.12\linewidth}
\begin{tikzpicture}
[
pie chart,
slice type={inlined}{lightgray},
slice type={noninlined}{darkgray},
pie values/.style={font={\tiny}},
scale=0.7
]
\pie{benchmark1}{14/inlined,43/noninlined}

\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.2\linewidth}
\begin{tikzpicture}
[
pie chart,
slice type={inlined}{lightgray},
slice type={noninlined}{darkgray},
pie values/.style={font={\tiny}},
scale=0.7
]
\pie{benchmark2}{34/inlined,9/noninlined}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.12\linewidth}
\begin{tikzpicture}
[
pie chart,
slice type={inlined}{lightgray},
slice type={noninlined}{darkgray},
pie values/.style={font={\tiny}},
scale=0.7
]
\pie{benchmark3}{14/inlined,43/noninlined}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.12\linewidth}
\begin{tikzpicture}
[
pie chart,
slice type={inlined}{lightgray},
slice type={noninlined}{darkgray},
pie values/.style={font={\tiny}},
scale=0.7
]
\pie{benchmark4}{34/inlined,9/noninlined}

 \end{tikzpicture}
 \end{minipage}
 \end{figure}

\begin{figure}
\begin{minipage}{0.4\linewidth}
\pgfplotsset{width=5cm}
\begin{tikzpicture}
\begin{ternaryaxis}[ 
xmin=0,
xmax=100,
ymin=0,
ymax=100,
zmin=0,
zmax=100, 
font=\scriptsize,
xlabel=frequency,
ylabel=size,
zlabel=monomorphism,
minor tick num=3,
grid=both, 
title={\textbf{benchmark}},
cycle list={{fill=darkgray, mark = triangle*}, 
{fill=lightgray, mark=*}},
legend cell align=left,
legend entries={Inlined, Not inlined},
legend style={mark size=2.6pt, at={(0,1)},
font=\scriptsize,
anchor=south,at={(axis description cs:0.5,-0.8)}},
mark size=2.6pt,
]
\addplot3+[only marks] 
 coordinates {
 (20, 20, 40)
 };
 \addplot3+[only marks] 
 coordinates {
 (10, 80, 10)
 };
\end{ternaryaxis}
\end{tikzpicture}
\end{minipage}
\pgfplotsset{width=3.3cm}
\begin{minipage}{0.1\linewidth}
\begin{tikzpicture}
 \begin{ternaryaxis}[
ticks=none,
 xmin=0,
 xmax=100,
 ymin=0,
 ymax=100,
 zmin=0,
 zmax=100, 
 mark size=2pt,
 font=\tiny,
 minor tick num=0,
 cycle list={{fill=darkgray, mark = triangle*}, 
 {fill=lightgray, mark=*}},
 title={\bf{benchmark1}},
 grid=both,
 minor tick num=2,
]
\addplot3+[only marks] 
 coordinates {
 (20, 40, 20)
 };
 \addplot3+[only marks] 
 coordinates {
 (10, 10, 80)
 };
\end{ternaryaxis}
\end{tikzpicture}
\end{minipage}
 \pgfplotsset{width=3.3cm}
  \begin{minipage}{0.1\linewidth}
  \begin{tikzpicture}
  \begin{ternaryaxis}[
  ticks=none,
 xmin=0,
xmax=100,
ymin=0,
ymax=100,
zmin=0,
zmax=100, 
mark size=2pt,
font=\tiny,
 minor tick num=2,
 grid=both,
 cycle list={{fill=darkgray, mark = triangle*}, 
 {fill=lightgray, mark=*}},
 title={\bf{benchmark2}}
 ]
\addplot3+[only marks] 
 coordinates {
 (15, 45, 40)
 };
 \addplot3+[only marks] 
 coordinates {
 (33, 33, 33)
 };
\end{ternaryaxis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.1\linewidth}
\begin{tikzpicture}
\begin{ternaryaxis}[
ticks=none,
 xmin=0,
 xmax=100,
 ymin=0,
 ymax=100,
 zmin=0,
 zmax=100, 
 mark size=2pt,
 font=\tiny,
 minor tick num=2,
 grid=both,
 cycle list={{fill=darkgray, mark = triangle*}, 
{fill=lightgray, mark=*}},
title={\bf{benchmark3}}
]
\addplot3+[only marks] 
 coordinates {
 (15, 45, 40)
 };
 \addplot3+[only marks] 
 coordinates {
 (33, 33, 33)
 };
 \end{ternaryaxis}
 \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.1\linewidth}
\begin{tikzpicture}
\begin{ternaryaxis}[
 ticks=none,
xmin=0,
xmax=100,
ymin=0,
ymax=100,
zmin=0,
zmax=100, 
mark size=2pt,
font=\tiny,
minor tick num=2,
grid=both,
cycle list={{fill=darkgray, mark = triangle*}, 
{fill=lightgray, mark=*}},
title={\bf{benchmark4}}
]
\addplot3+[only marks] 
 coordinates {
 (15, 45, 40)
 };
 \addplot3+[only marks] 
 coordinates {
 (33, 33, 33)
 };
\end{ternaryaxis}
\end{tikzpicture}
\end{minipage}
\end{figure}
\end{document}

관련 정보