有没有办法在 Plotly(特别是 R)中隐藏跟踪名称?

Is there a way to hide Trace Names in Plotly (specifically R)?

我一直在绞尽脑汁思考如何用 plotly 去掉跟踪名称,但似乎找不到任何东西。添加跟踪名称似乎是 plotly boxplots 的一个独特功能。我可以将它命名为“”,但我需要原始迹线名称,以便在覆盖标记时可以引用它。我已尽可能简化代码以解决根本问题。有没有办法隐藏跟踪名称?

housing = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data")
colnames(housing) = c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV")

housing %>%
  plot_ly( x = ~RM, 
        type="box", 
        name = "RM",
        showlegend = FALSE
        ) %>% 
  add_markers(x=6, y="RM",
            marker = list(color = "blue", size = 15)
            )

如果您想在箱形图中隐藏轨迹名称,可以使用 showticklabels = F 隐藏轴的标签。

在下面的示例中,跟踪名称也通过设置 hoverinfo = 'x' 隐藏在悬停标签中。

library(plotly)
housing = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data")
colnames(housing) = c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV")

housing %>%
  plot_ly( x = ~RM,
           y = 'RM',
           type="box", 
           name = "RM",
           showlegend = FALSE,
           hoverinfo = 'x'
  ) %>% 
  add_markers(x=6, y="RM",
              marker = list(color = "blue", size = 15)
  ) %>% layout(yaxis = list(showticklabels = F))
housing