
xbar スタック スタイルのプロットを作成したいのですが、一部の ylabel をグループ化する必要があります。
この質問と解決策を見つけましたpgfplots で「ybar」と「ybar stacked」を混在させるにはどうすればよいですか?ですが、私にとっては理解しにくいです。また、これは ybars 用であり、xbars を使用する必要があります。グループには複数のレベルもありますが、1 つのレベルでグループ化するだけで済みます。
\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}
誰か何か提案があれば、何でも歓迎します :)!