在plotly的子图中抑制痕迹颜色和图例

时间:2017-04-04 05:57:26

标签: r legend plotly

我在plotly中生成R个数字列表:

set.seed(1)
scatter.list <- vector(mode="list",3)
require(plotly)

for(i in 1:3){
  df <- data.frame(x=rnorm(100),y=rnorm(100),a=LETTERS[sample(26,100,replace=T)])
  scatter.list[[i]] <- plot_ly(type='scatter',mode="markers",x=~df$x,y=~df$y,text=~df$a,data=df) %>%
    layout(xaxis=list(title=xlab,zeroline=F),yaxis=list(title=ylab,zeroline=F))
}

然后想用subplot

绘制它们
plotly::subplot(scatter.list,nrows=3,titleX=T,titleY=T)

给出了: enter image description here

我的问题是如何让所有子图中的所有点都采用相同的颜色以及如何抑制图例?

1 个答案:

答案 0 :(得分:2)

您可以通过$(document).on "fields_added.nested_form_fields", (event, param) -> field = $(event.target).find('.has-placeholder') $(field).attr('placeholder', placeholders[Math.floor(Math.random()*placeholders.length)]);

手动隐藏包含showlegend = FALSE的图例和设置的标记颜色

enter image description here

markers = list('color' = myColor))