R 如何制作堆叠面积图?

R 如何制作堆叠面积图?,r,ggplot2,R,Ggplot2,我正在尝试制作堆叠面积图: library(ggplot2) ggplot(data, aes(x = variable, y = value, fill = term)) + geom_area() 但这导致了一个空白的情节 预期图(示例) 我该怎么做 data <- structure(list(term = c("models", "percentiles", "models:percentiles",

我正在尝试制作堆叠面积图:

library(ggplot2)

ggplot(data, aes(x = variable, y = value, fill = term)) +
   geom_area()
但这导致了一个空白的情节

预期图(示例)

我该怎么做

data <- structure(list(term = c("models", "percentiles", "models:percentiles", 
                                "models", "percentiles", "models:percentiles", 
                                "models", "percentiles", "models:percentiles"), 
                       variable = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), 
                                            .Label = c("R2", "R5", "R10"), class = "factor"), 
                       value = c(0.435697205847009, 0.533615307749147, 0.0306874864038442, 
                                 0.441369621882273, 0.520198994695284, 0.0384313834224421, 
                                 0.394491546635206, 0.579421546902868, 0.0260869064619254)), 
                  row.names = c(NA, -9L), class = "data.frame")

数据您只缺少
美学:

ggplot(data, aes(x = variable, y = value, group = term, fill = term)) +
    geom_area(color = "black")