为什么填充比例不会出现在ggplot图例中?

时间:2017-04-16 04:43:10

标签: r ggplot2

在以下示例中(通常,最有可能),为什么填充比例不会出现在图例中?我该如何将其添加回来?

library(ggplot2)
df <- data.frame(
    iteration = c(0L, 1L, 2L, 3L, 4L, 5L, 0L, 1L, 2L, 3L, 4L, 5L), 
    simulated = c(FALSE, FALSE, FALSE, FALSE, FALSE,  FALSE, TRUE, TRUE, TRUE, 
                  TRUE, TRUE, TRUE),
    y = c(0.489208756134596, 0.446671432623037, 0.394899619612221,
          0.401666567262662, 0.401388987933964, 0.40341958452576,
          0.489208756134596, 0.557507061234589, 0.456335353578318, 
          0.432985087590292, 0.41986196428934, 0.414269421382366),
    ymin = c(0.489208756134596, 0.415748094328659, 0.38129465868997, 
             0.389207695070269, 0.391264736511511, 0.393762124846039, 
             0.489208756134596, 0.471180466395192, 0.385448865437948, 
             0.388097695909196, 0.386228763055259, 0.381851160280109), 
    ymax = c(0.489208756134596, 0.471239502841001, 0.406915871212101, 
             0.411494996198763, 0.409437933325421, 0.409647885233173, 
             0.489208756134596, 0.681861349783727, 0.556151925152542, 
             0.500399891886999, 0.502007467288816, 0.47105796448803)
)

ggplot(df, aes(x = iteration, y = y, ymin = ymin, ymax = ymax, 
               fill = simulated)) + 
  geom_smooth(stat = "identity")

example plot

0 个答案:

没有答案