如何解决使用变换过滤器时R特意更新标题
我创建了一个图形,可让您选择要绘制的组数据。当您选择群组时,我想更改标题,但不确定如何或是否可能。我在学习哪种结构来构造某些绘图参数的列表时遇到了麻烦。即使我可以在图形中添加自定义文本也可能会起作用。
#Working Example so Far
library(plotly)
x <- c(1:100)
random_y <- rnorm(100,mean = 0)
random_y_prim <- rnorm(100,mean = 50)
mydata <- data.frame(x,random_y,random_y_prim,group = rep(letters[1:4],25))
# Make Group List Button
groupList <- unique(mydata$group)
groupLoop <- list()
for (iter in 1:length(groupList)) {
groupLoop[[iter]] <- list(method = "restyle",args = list("transforms[0].value",groupList[iter]),label = groupList[iter])
}
# Set up Axis labeling
f <- list(
family = "Verdana",size = 18,color = "#7f7f7f"
)
xLab <- list(
title = "x Axis",titlefont = f
)
yLab <- list(
title = "y Axis",titlefont = f
)
fig <- plot_ly(mydata,x = ~x,y = ~random_y,type = 'scatter',mode = 'lines',transforms = list(
list(
type = 'filter',target = ~mydata$group,operation = '=',value = groupList[1]
)
)
)
fig <- fig %>%
layout(
title = "Updating Practice",xaxis = xLab,yaxis = yLab,updatemenus = list(
list(
type = 'dropdown',xanchor = 'center',yanchor = "top",active = 1,buttons = groupLoop
)
)
)
fig
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。