R中的plot_ly函数

时间:2018-02-09 00:16:30

标签: r plot plotly r-plotly

我看看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"))

1 个答案:

答案 0 :(得分:0)

在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"))