I have two questions regarding the pgfplots package. I have attached the source code I worked on. There are two features I am not able to realize:
I would like to put the total value (sum of the whole stacked bar) on top of the bar, rotated by
90°. For me, it was only possible yet to get the value of each part of the stacked bar by using thenodes near coordscommand.Additionally, the percentage of each part of the stacked bar as relative to the whole stacked bar should be displayed in the bar, also rotated by
90°(addition equals100%)
If it is somehow possible, percentages should have only one significant digit, and those below 5% should not be displayed in the bar. I know this is a pretty complex example, but maybe there is one who can solve it.
\documentclass{article}
\usepackage{pgfplots,pgfplotstable}
\usetikzlibrary{pgfplots.groupplots}
\pgfplotsset{compat=1.8}
\pgfplotstableread{
Criterion ddd ccc vvv
(0) 700 750 750
(a) 700 750 750
(b) 1200 750 750
(c) 33 345 345
(d) 34 333 345
(e) 234 344 344
}\Rob
\pgfplotstableread{
Criterion ddd ccc vvv
0 70 75 75
a 70 75 75
b 120 75 75
c 3 34 34
d 3 33 34
e 23 34 34
}\Gab
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style= {
columns=2,xlabels at=edge bottom,
ylabels at=edge left,
horizontal sep=1cm,group name=plots,
},
ymin=0, enlarge x limits={abs=.5}, enlarge y limits={upper,value=0.4},
ylabel=Mon, ylabel style={text height=0.02\textwidth,inner ysep=0pt},
ybar,ybar stacked,
major x tick style = transparent,
/pgf/bar shift=0pt, /pgf/bar width=9pt,
x tick label style={text height=2ex},
xlabel style={yshift=-2ex},
xticklabels from table={\Rob}{Criterion},
xtick=data,legend columns=-1, legend style={draw=none, /tikz/every even column/.append style={column sep=5pt}}]
\nextgroupplot[xlabel=Rob, xlabel shift = -7.5cm, legend to name=grouplegend]
\pgfplotstableforeachcolumn\Rob\as\col{
\ifnum\pgfplotstablecol=0
\else
\edef\tmp{
\noexpand\addplot table [x expr=\noexpand\coordindex,y=\col] {\noexpand\Rob};
\noexpand\addlegendentry {\col}
}
\tmp
\fi
}
\nextgroupplot[xlabel=Gab, xlabel shift = -7.5cm]
\pgfplotstableforeachcolumn\Gab\as\col{
\ifnum\pgfplotstablecol=0
\else
\edef\tmp{
\noexpand\addplot table [x expr=\noexpand\coordindex,y=\col] {\noexpand\Gab};
}
\tmp
\fi
}
\end{groupplot}
\draw[dashed] (plots c1r1.south west) -- ++(0,-1.5);
\draw[dashed] (plots c1r1.south east) -- ++(0,-1.5);
\draw[dashed] (plots c2r1.south west) -- ++(0,-1.5);
\draw[dashed] (plots c2r1.south east) -- ++(0,-1.5);
\node at (plots c1r1.south) [inner sep=0pt,anchor=north, yshift=-12ex] {\ref{grouplegend}};
\end{tikzpicture}
\end{document}

visualization depends onkeys, but at the moment they're broken for stacked plots, unfortunately. See http://tex.stackexchange.com/questions/86369/stacked-bar-plots-with-several-descriptive-nodes. – Jake Jun 12 '13 at 03:24