geom_line和团体美学

时间:2019-05-29 13:39:37

标签: r ggplot2 aesthetics

geom_line函数未考虑ggplot函数提供的分组美观性

model <- lm(bd[,8]~bd[,2], bd)
summary(model)
bd <- cbind(bd, predict.lm(model, interval = "prediction"))
loc <- as.factor(bd[,5])
phyl <-as.factor(bd[,4])
bd <- as.data.frame(bd)
fitlwr <- bd[,10]
fitupr <- bd[,11]

X <- ggplot(bd, aes(group=loc))+ 
  geom_line(aes(y=lwr), color = "red", linetype = "dashed")+
  geom_line(aes(y=upr), color = "red", linetype = "dashed")+
  geom_point(aes(bd[,2], bd[,8], alpha=0.2, color=phyl,size=1)) + 
  geom_smooth(method="lm", formula=y~x, se=T, aes(group=loc)) +
  theme_minimal() +
  theme(legend.position = "bottom") +
  theme(axis.text=element_text(size=7), axis.title.x=element_text(size=11), axis.title.y=element_text(size=11)) + 
  xlab("GM") + 
  ylab("ZC") 
X

ggplot实际上是在绘制upr和lwr预测值,但没有考虑ggplot函数中提供的分组美观性

0 个答案:

没有答案