堆叠的ggplot2 geom_area重新运行一个空图

我试图给我们geom_area生成一个堆积的面积图,但它生成一个入口图。这是一个例子

library(dplyr)
library(ggplot2)

x = expand.grid(name = c("D01", "D02", "D03", "D04"), component = c("F", "W", "M", "V"))
value = runif( min = 20, max = 150, nrow(x))

data2 = cbind(x, value) %>%
  dplyr::arrange(name)

ggplot2::ggplot(data = data2, aes(x = name, fill = factor(component))) + 
                  ggplot2::geom_area(aes(y = value), position = 'stack') 

I read the questions Why is my stacked area graph in ggplot2 empty and Why is my stacked area graph in ggplot2 empty but the solutions posted there they did not resolve my problem. Thanks for any suggestions.

评论