[英]ggplot2 (scatter plot and several fitted values) in R
How I can modify the following code to have a plot between x and y (scatter plot) and the fitted values X0.025 and y=X0.975 as the curves (lines) on the plot. 我如何修改以下代码以在x和y(散点图)之间绘制曲线,并将拟合值X0.025和y = X0.975作为曲线上的曲线(线)。 (please run plot(m6)
to see the plot which I am looking for to make by ggplot
) (请运行plot(m6)
以查看我要通过ggplot
进行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)
I tried to make this plot by ggplot and here is the code: 我试图通过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()
Are you looking for this? 您在找这个吗?
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.