r-plotly - 需要一些建议

r-plotly - Need some advice

我如何在 R 中使用 library(plotly) 将以下图表引入网络?

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)