我有两个县的人口数据集随着时间的推移:如何使用ggplot将阴影区域添加到包含多行的折线图?
dat <- data.frame(Year=rep(c(2012, 2013, 2014, 2015), each=2),
Region=rep(c("County1", "County2"), 4),
Count=c(125082, 122335, 126474, 121661, 128220, 121627, 130269, 121802))
我能够做一个折线图就好了:
ggplot(data=dat, aes(x=Year, y=Count, group=Region, fill = Region)) +
geom_line()
不过,我想超级酷,并填充颜色线下方的区域。当我尝试使用geom_area(),它似乎在county1堆放county2:
ggplot(dat, aes(x=Year, y=Count, fill = Region)) + geom_area()
这不是我想要的。感谢您的帮助!
退房'geom_ribbon' – ddunn801