0

I look at Plotly guideline but I could not find a way to rename x and y labels. Any advice?

 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"))
MLavoie
  • 9,671
  • 41
  • 36
  • 56
shoo
  • 87
  • 1
  • 11

1 Answers1

0

In R, you store that info in lists. Like this

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"))
erocoar
  • 5,723
  • 3
  • 23
  • 45
  • @ erocoar, thanks so much, I have a question when I use p3<-subplot(p1) the function again remove x and y label. any solution for this? – shoo Feb 09 '18 at 01:18
  • Yes, `subplot(..., titleX = TRUE, titleY = TRUE)` to keep the axis titles – erocoar Feb 09 '18 at 17:39