I've been wracking my brain over how to get rid of the trace name with plotly and can't seem to find anything. It seems adding the trace name is a unique feature of plotly boxplots. I could just name it " " but I need the original trace name so that I can reference it when overlaying a marker. I've simplified the code as much as possible to the root issue. Is there a way to hide the trace name?
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)
)
If you want to hide the trace names in a box chart, you could hide the axis' labels by using showticklabels = F
.
In the example below the trace name is also hidden in the hover labels by setting 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With