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(stat = "identity") +
ggplot2::labs(
title = "Stacked Bar Chart",
x = "Groups",
y = "Count"
) +
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