MENU

Fun & Interesting

Creating a stacked barchart in R with ggplot2 (CC102)

Riffomonas Project 35,550 4 years ago
Video Not Working? Fix It Now

A stacked barchart is a common approach to depicting relative abundance data in microbiome studies. How do you create stacked barplots in R with ggplot2? Shouild you even be creating stacked bar plots? Check out this episode of Code Club to learn how to create those iconic stacked bar charts and Pat will also tell you why they're problematic. Pat will use RStudio and the #geom_col function from the #ggplot2 package and functions from other parts of the #tidyverse. The accompanying blog post can be found at https://riffomonas.org/code_club/2021-05-10-stacked-barcharts Do you have a figure that you would like to receive a critique or help improving? Let me know and I'd be happy to arrange a guest appearance! If you're interested in taking an upcoming 3 day R workshop, email me at [email protected]! R: https://r-project.org RStudio: https://rstudio.com Raw data: https://github.com/riffomonas/raw_data/releases/latest Workshops: https://www.mothur.org/wiki/workshops You can also find complete tutorials for learning R with the tidyverse using... Microbial ecology data: https://www.riffomonas.org/minimalR/ General data: https://www.riffomonas.org/generalR/ 0:00 Introduction 2:44 Aggregating relative abundances 7:58 Building stacked barchart 9:21 Improving appearance of labels 12:48 Improving appearance of legend 16:56 Critique of figure 21:00 Recap

Comment