如何修改以下代码,使得x和y之间的图(散点图)和拟合值X0.025和y = X0.975作为图上的曲线(线)。 (请运行plot(m6)
查看我想要ggplot
制作的情节
library(quantregGrowth)
data(growthData)
m6<-gcrq(y~ps(x, lambda=seq(0,100,l=20)), tau=c(0.025,0.975), n.boot=10,
data=growthData)
plot(m6)
我试图通过ggplot创建这个图,这里是代码:
library(ggplot2)
library(plotly)
temp <- data.frame(m6$fitted)
growthData_b <- cbind(growthData, temp)
a <- ggplot(data=growthData_b, aes(x, y=X0.025)) + geom_line() +
geom_line(data=growthData_b, aes(x, y=X0.975), color = "red") + theme_bw()
答案 0 :(得分:0)
你在找这个吗?
ggplot(data=growthData_b, aes(x, y=X0.025)) +
geom_line() +
geom_line(data=growthData_b, aes(x, y=X0.975), color = "red", linetype = 2) +
theme_bw() +
geom_point(aes(x=x, y=y), shape = 1)