그룹화로 쌓인 pgfplots xbar

그룹화로 쌓인 pgfplots xbar

xbar 스택 스타일로 플롯을 만들고 싶지만 일부 ylabel을 함께 그룹화해야 합니다.

이 질문과 해결책을 찾았습니다pgfplots에 "ybar"와 "ybar stacked"를 어떻게 혼합할 수 있나요?, 하지만 나에게는 이해하기 쉽지 않습니다. 또한 ybar용이므로 xbar를 사용해야 합니다. 여러 수준의 그룹도 있지만 한 수준으로만 그룹화하면 됩니다.

\documentclass{standalone}
\usepackage{pgfplots, pgfplotstable}
\begin{document}
\pgfplotstableread[col sep=space, header=false]{
5-16-64KiB-128KiB   0.555776    0.196256 0.005536 0.098208 0.133056
5-16-1MiB-2MiB      0.52304     0.126112 0.005472 0.064448 0.08448
5-32-64KiB-128KiB   0.36992     0.377856 0.005504 0.090304 0.110208
5-32-1MiB-2MiB      0.336352    0.252224 0.005568 0.06496  0.092384
10-16-64KiB-128KiB  0.399488    0.377952 0.005568 0.109184 0.140096
10-16-1MiB-2MiB     0.366976    0.252128 0.005472 0.07088  0.084832
10-32-64KiB-128KiB  0.397312    0.629408 0.005568 0.096768 0.125408
10-32-1MiB-2MiB     0.349664    0.37792  0.005632 0.070784 0.079872
15-16-64KiB-128KiB  0.477472    0.573536 0.005504 0.092192 0.120992
15-16-1MiB-2MiB     0.436576    0.377728 0.005504 0.065248 0.088416
15-32-64KiB-128KiB  0.46848     0.769408 0.005504 0.155744 0.190272
15-32-1MiB-2MiB     0.342144    0.755168 0.005472 0.0728   0.092768
}\datatable
\begin{tikzpicture}
  \begin{axis}[
    width=\textwidth, %
    xbar stacked, %
    y=-0.5cm,%
    bar width=0.3cm,%
    yticklabels from table={\datatable}{0},%
    enlarge y limits={abs=0.45cm},%
    ytick=data,%
    xlabel={Ausführungszeit in ms}, %
    ylabel={Parameter}, %
    xmin=0.0, xmax=2.0, %
    legend pos=south east, %
    ]%
\addplot table [x=1, y expr=\coordindex] {\datatable};
\addplot table [x=2, y expr=\coordindex] {\datatable};
\addplot table [x=3, y expr=\coordindex] {\datatable};
\addplot table [x=4, y expr=\coordindex] {\datatable};
\addplot table [x=5, y expr=\coordindex] {\datatable};
\legend{%
}    
\end{axis}
\end{tikzpicture}
\end{document}

이 이미지는 위의 최소 예의 결과입니다.

내가 가진 것

나는 그런 것을 원합니다 :

내가 원하는 것

정보를 표시하는 방법이 너무 복잡하거나 좋지 않은 경우: 이 정보를 플롯으로 표시할 수 있는 다른 방법이 있습니까?

편집: 좋아요, 그룹화된 xbar에 대해 위 링크의 코드를 변환하려고 했습니다.

\newcounter{groupcount}
\pgfplotsset{
    draw group line/.style n args={5}{
        after end axis/.append code={
            \setcounter{groupcount}{0}
            \pgfplotstableforeachcolumnelement{#1}\of\datatable\as\cell{%
                \def\temp{#2}
                \ifx\temp\cell
                    \ifnum\thegroupcount=0
                        \stepcounter{groupcount}
                        \pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
                        \coordinate [xshift=#4] (startgroup) at (axis cs:0,\pgfplotsretval);
                    \else
                        \pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
                        \coordinate [xshift=#4] (endgroup) at (axis cs:0,\pgfplotsretval);
                    \fi
                \else
                    \ifnum\thegroupcount=1
                        \setcounter{groupcount}{0}
                        \draw [
                            shorten >=-#5,
                            shorten <=-#5
                        ] (startgroup) -- node [anchor=east] {#3} (endgroup);
                    \fi
                \fi
            }
            \ifnum\thegroupcount=1
                        \setcounter{groupcount}{0}
                        \draw [
                            shorten >=-#5,
                            shorten <=-#5
                        ] (startgroup) -- node [anchor=east] {#3} (endgroup);
            \fi
        }
    }
}


\pgfplotstableread[col sep=semicolon, header=false]{
X;C;M;K1;K2;K3;M1;M2
1;1;1;0.555776;0.196256;0.005536;0.098208;0.133056
2;1;2;0.52304;0.126112;0.005472;0.064448;0.08448
4;2;1;0.36992;0.377856;0.005504;0.090304;0.110208
5;2;2;0.336352;0.252224;0.005568;0.06496;0.092384
7;3;1;0.399488;0.377952;0.005568;0.109184;0.140096
8;3;2;0.366976;0.252128;0.005472;0.07088;0.084832
10;4;1;0.397312;0.629408;0.005568;0.096768;0.125408
11;4;2;0.349664;0.37792;0.005632;0.070784;0.079872
13;5;1;0.477472;0.573536;0.005504;0.092192;0.120992
14;5;2;0.436576;0.377728;0.005504;0.065248;0.088416
16;6;1;0.46848;0.769408;0.005504;0.155744;0.190272
17;6;2;0.342144;0.755168;0.005472;0.0728;0.092768
}
\begin{tikzpicture}
\begin{axis}[
    xlabel={Ausführungszeiten in ms}, %
    ylabel={Parameter}, %
    width=\textwidth, %
    y=-0.4cm,%
    bar width=0.3cm,%
    enlarge y limits={abs=0.45cm},%
    legend pos=north east, %
    area legend, %
    ytick=data, %
    ylabel near ticks, %
    yticklabels from table={\datatable}{M},
    xmin=0.0,xmax=2.0, %
    xtick={0.0,0.2,...,2.0}, %
    xbar stacked, %
    bar width=10pt, %
    area legend, %
    draw group line={C}{1}{5/16}{-80pt}{8pt},
    draw group line={C}{2}{5/32}{-80pt}{8pt},
    draw group line={C}{3}{10/16}{-80pt}{8pt},
    draw group line={C}{4}{10/32}{-80pt}{8pt},
    draw group line={C}{5}{15/16}{-80pt}{8pt},
    draw group line={C}{6}{16/32}{-80pt}{8pt},
]\datatable
\addplot table[x=K1,y=X] \datatable;\addlegendentry{1}
\addplot table[x=K2,y=X] \datatable;\addlegendentry{2}
\addplot table[x=K3,y=X] \datatable;\addlegendentry{3}
\addplot table[x=M1,y=X] \datatable;\addlegendentry{4}
\addplot table[x=M2,y=X] \datatable;\addlegendentry{5}
\end{axis}
\end{tikzpicture}

누군가 제안 사항이 있으면 무엇이든 환영합니다 :)!

관련 정보