答案 0 :(得分:0)
没有提供数据,所以我创建了一个虚拟数据。我在下面创建了一个用例,否则有关于SO的解决方案,例如Simplest way to do grouped barplot。
library(tidyverse)
# Data
trees <- data.frame(age = sample(c("Old", "Adult", "Young"),
size = 20, replace = TRUE, prob = c(.5, .25, .25)),
tree = factor(sample(1:5, size = 20, replace = TRUE)),
circumference = rnorm(n = 20, mean = 60, sd = 15))
trees %>%
ggplot(aes(x = age, y = circumference, fill = tree)) +
geom_col(position = "dodge") +
coord_flip()