data <- data.frame( Category = c("Category 1", "Category 2", "Category 3", "Category 1", "Category 2", "Category 3"), Group = c("Group A", "Group A", "Group A", "Group B", "Group B", "Group B"), Count = c(10, 15, 5, 8, 12, 7) ) ggplot2::ggplot(data, ggplot2::aes(x = Group, y = Count, fill = Category)) + ggplot2::geom_bar(position = "fill", stat = "identity") + ggplot2::geom_text(aes(label = scales::percent(Count / sum(Count))), position = ggplot2::position_fill(vjust = 0.5)) + ggplot2::labs(title = "100% Stacked Bar Chart", x = "Groups", y = "Proportion") + ggplot2::scale_y_continuous(labels = scales::percent_format(scale = 100)) + ggplot2::theme_minimal()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter