I have a bar plot with grouped bars. Each group should contain the total sum on top of the group.
Example:

My example has two problems:
- The x-position is estimated
- The y-psition (height) depends on the 2nd bar
How can I get the sums to their correct positions?
The example is created with this code:
\documentclass[border=5mm] {standalone}
\usepackage{pgfplots, pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Test},
ybar, ymin=3,
bar width=5mm,
enlarge y limits ={value=0.3,upper},
symbolic x coords={a,b,c,d},
xtick=data,
nodes near coords,
nodes near coords align={anchor=north},%Move values in bar anchor=mid
]
%Active
\addplot [fill=blue] coordinates {
({a},15) [xa]
({b},25)
({c},35)
({d},55)};
\addlegendentry{Active}
%Inactive
\addplot [fill=red] coordinates {
({a},60)
({b},50)
({c},40)
({d},30)}
[yshift=5mm]
node[pos=0] {a: 75}
node[pos=.25] {b: 75}
node[pos=.5] {c: 75}
node[pos=1] {d: 45};
\addlegendentry{Inactive}
\end{axis}
\end{tikzpicture}
\end{document}
Remarks:
- This is a follow up of another question: How can I get a stacked bar with single values and sum on top.
- There is already a similar question using bar chart to compare two groups of data, how to draw one node (showing the ratio) per two bars?
- There is no need to calculate the sum. The code is generated and my generator can calculate the sum. But it would be nice, if it would be possible to calculate sum of each group.

axis csdefines the x-coordinate - great! Did I understand correct: for the height you take the biggest value + 5? – knut Aug 24 '13 at 00:01