R geom_区域正在返回一个空图形
我想根据以下数据绘制水平衡图:R geom_区域正在返回一个空图形,r,plot,ggplot2,R,Plot,Ggplot2,我想根据以下数据绘制水平衡图: mes ND NDA T P N ETP Balanco pos neg JAN 31 1 19.22581 232.3 13.347611 91.43498 140.865023 140.86502 0.000000 FEV 28 32 19.86429 114.3 12.999102 84.90256 29.397440 29.39744 0.000000 MAR
mes ND NDA T P N ETP Balanco pos neg
JAN 31 1 19.22581 232.3 13.347611 91.43498 140.865023 140.86502 0.000000
FEV 28 32 19.86429 114.3 12.999102 84.90256 29.397440 29.39744 0.000000
MAR 31 60 19.30968 141.5 12.460415 85.97512 55.524884 55.52488 0.000000
ABR 30 91 16.26000 201.2 11.498742 57.75492 143.445078 143.44508 0.000000
MAI 31 121 14.24839 83.6 10.167309 42.40138 41.198623 41.19862 0.000000
JUN 30 152 14.53667 123.0 8.741137 36.46793 86.532073 86.53207 0.000000
JUL 31 182 11.76452 44.0 8.477178 25.74084 18.259155 18.25916 0.000000
AGO 31 213 10.90645 2.5 9.678359 25.92338 -23.423384 0.00000 -23.423384
SET 30 244 14.25333 35.5 11.109252 44.86090 -9.360903 0.00000 -9.360903
OUT 31 274 16.77097 153.6 12.232699 66.82824 86.771759 86.77176 0.000000
NOV 30 305 18.59333 109.9 12.869165 80.71515 29.184855 29.18485 0.000000
DEZ 31 335 20.22903 121.0 13.288338 99.03102 21.968977 21.96898 0.000000
链接到数据:
使用geom_栏,可以:
mensal$mes = factor(mensal$mes,
levels=c("JAN", "FEV", "MAR", "ABR", "MAI", "JUN",
"JUL", "AGO", "SET", "OUT", "NOV", "DEZ"))
ggplot(mensal) +
geom_bar(aes(x = mes, y = pos), stat = "identity", fill = "blue") +
geom_bar(aes(x = mes, y = neg), stat = "identity", fill = "red")
但我想使用面积,类似于此:
。。。在这种情况下,使用geom_area时,我的图形返回为空:
ggplot(mensal) +
geom_area(aes(x = mes, y = pos), fill = "blue") +
geom_area(aes(x = mes, y = neg), fill = "red")
有什么想法吗?我做错了什么?发布答案只是为了防止错误信息:
gg <- ggplot(mensal, aes(group=1))
gg <- gg + geom_area(aes(x = mes, y = pos), fill = "blue")
gg <- gg + geom_area(aes(x = mes, y = neg), fill = "red")
gg <- gg + theme_bw()
gg <- gg + theme(panel.grid=element_blank())
gg <- gg + theme(panel.border=element_blank())
gg
gg将aes(组=1)
添加到您的ggplot(mensal)
Uau!太简单了!Tks!