plot_ly R 中的函数

plot_ly function in R

我查看了 Plotly 指南,但找不到重命名 x 和 y 标签的方法。有什么建议吗?

 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) 

 library(ggplot2)
 library(plotly)
 temp <- data.frame(m6$fitted)
 growthData_b <- cbind(growthData, temp)

p1<-plot_ly(growthData_b, x = ~x, y = ~y) %>% add_lines(data = growthData_b, x = ~x, y = ~X0.025,name = "0.025 percentile",color = I("black"))%>% 
add_lines(data = growthData_b, x = ~x, y = ~X0.975,name = "0.975 percentile",color = I("black"))%>%add_markers(x = ~x, y = ~y,color =I("blue"))

在 R 中,您将该信息存储在列表中。像这样

p1<-plot_ly(growthData_b, x = ~x, y = ~y) %>% 
  add_lines(data = growthData_b, x = ~x, y = ~X0.025,name = "0.025 percentile",color = I("black")) %>% 
  add_lines(data = growthData_b, x = ~x, y = ~X0.975,name = "0.975 percentile",color = I("black")) %>%
  add_markers(x = ~x, y = ~y,color =I("blue")) %>% 

  layout(xaxis = list(title = "X Axis"), yaxis = list(title = "Y Axis"))