如何library(plotly)
在 R 中使用将以下情节带入网络?
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)
library(ggplot2)
library(plotly)
temp <- data.frame(m6$fitted)
growthData_b <- cbind(growthData, temp)
选项 1 是使用ggplotly()
:
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() +
ylab('fitted')
ggplotly(a)
选项 2 是使用plot_ly()
:
plot_ly() %>% add_lines(data = growthData_b, x = ~x, y = ~X0.025) %>% add_lines(data = growthData_b, x = ~x, y = ~X0.975)