我一直在绞尽脑汁地想办法如何用图谋摆脱痕迹名称,似乎什么也找不到。似乎添加跟踪名称是绘图框图的独特功能。我可以将其命名为“”,但是我需要原始的跟踪名称,以便在覆盖标记时可以引用它。我已将代码尽可能简化为根本问题。有没有办法隐藏跟踪名称?
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)
)
答案 0 :(得分:2)
如果您想在箱形图中隐藏轨迹名称,则可以使用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