I've got some bar graphs that look a bit like this: enter image description here

Wondering if it's possible to make them look like this below (I've been calling it a cumulative bar graph, but now that i think about it, perhaps that's not the right word): enter image description here

Here's the MWE. It was pinched from an older project, so it might have a few unnecessary artifacts.

declare function={barheight=5pt;}}
\begin{tikzpicture}[y=0.3cm, x=0.06cm]
\foreach [count=\i from 0] \p/\t in{
{\node [anchor=base east, barlabels, name=i-\i] at (0,-\i) {\t};
\fill [red!50] (i-\i.base east) rectangle ++({((\p)-13)*0.6},barheight) ++(0,-barheight) node[barlabels, black, anchor=base west] {\p};
  • 5
    This looks awfully like a xbar stacked plot that can be found on p. 96 of the pgfplots manual v1.16. – Schrödinger's cat Oct 29 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.