R中的plot_ly函数
Posted
技术标签:
【中文标题】R中的plot_ly函数【英文标题】:plot_ly function in R 【发布时间】:2018-07-19 16:39:23 【问题描述】:我查看了 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】:在 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"))
【讨论】:
@erocoar,非常感谢,当我使用 p3 是的,subplot(..., titleX = TRUE, titleY = TRUE)
保留轴标题以上是关于R中的plot_ly函数的主要内容,如果未能解决你的问题,请参考以下文章