Grouped and Stacked barplot





Grouped and Stacked barplot display a numeric value for several entities, organised in groups and subgroups. It is probably better to have a solid understanding of the basic barplot first and this online course can help for this.

Step by step - ggplot2

ggplot2 is probably the best option to build grouped and stacked barchart. The input data frame requires to have 2 categorical variables that will be passed to the x and fill arguments of the aes() function. Toggling from grouped to stacked is pretty easy thanks to the position argument.




Circular Stacked Barchart

A barchart can look pretty good using a circular layout, even if there are some caveats associated. If it interests you, visit the circular barchart section.

Code Circular section




Stacked barplot for evolution

Stacked area chart are sometimes used to study an evolution using each group on the X axis as a timestamp. There are many alternatives to that, like streamgraph or area chart:

Learn more





Base R

A stacked area chart showing the evolution of a few baby names in the US. Zoom on a specific time frame through brushing. Highlight a specific group by hovering the legend. Double click to unzoom.

Related chart types


Grouped and Stacked barplot
Treemap
Doughnut
Pie chart
Dendrogram
Circular packing