r ggplot2使用几何校正忽略未知美学
我正在尝试绘制瀑布图,如以下示例所示:r ggplot2使用几何校正忽略未知美学,r,ggplot2,R,Ggplot2,我正在尝试绘制瀑布图,如以下示例所示: base2 <- data.frame(rot=c("PRini","shk1","PRfim"), value=c(10,5,15),order=c(1,2,3), fim=c(10,15,0), inicio=c(0,10,15), imp=c("net","pos","net")) ggplot(base2, aes(fill = imp)) + geom_rect(aes(x = rot,
base2 <- data.frame(rot=c("PRini","shk1","PRfim"), value=c(10,5,15),order=c(1,2,3), fim=c(10,15,0),
inicio=c(0,10,15), imp=c("net","pos","net"))
ggplot(base2, aes(fill = imp)) +
geom_rect(aes(x = rot,
xmin=order - 0.3,
xmax=order + 0.3,
ymin=fim,
ymax=inicio),
position="dodge")
base2在ggplot(aes())中添加所有美学元素,这样您就不会收到警告。geom_rect()将从ggplot()获取aes
另一个解决方案是肮脏的解决方法:
看来你的阴谋是好的,但它只是给你一个警告。您也可以使用suppressWarnings()
忽略警告。非常感谢,@missva11!这就是我一直在寻找的解决方案!就像你说的,情节很好,但我想删除警告
。
ggplot(base2, aes(fill = imp, x = rot, xmin=order - 0.3,
+ xmax=order + 0.3,
+ ymin=fim,ymax=inicio)) +
+ geom_rect( position="dodge")