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

rob*_*ars 4 r plotly r-plotly

我一直在绞尽脑汁想如何用 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)
            )
Run Code Online (Sandbox Code Playgroud)

Max*_*ers 5

如果要隐藏箱形图中的跟踪名称,可以使用 隐藏轴的标签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
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明