This should be easy to do, but the solution eludes me. How do I remove the legend in a contour plot made with plotly for R? This doesn't work for me.
# Reproducible example
p <- plot_ly(mtcars, x = ~wt, y = ~cyl, z = ~mpg, type = "contour")
hide_legend(p) # Doesn't work
p %>% layout(showlegend = FALSE) # Doesn't work
plot_ly(mtcars, x = ~wt, y = ~cyl, z = ~mpg, type = "contour", showlegend = FALSE) # Doesn't work
Actually, what I really want to do is to have a single legend for multiple contour plots in the same figure, but assigning them to the same legendgroup doesn't work either, so I'd rather label the contours and get rid of all the legends than have a dozen legends cluttering my plot:
plot_ly() %>%
add_trace(..., type = "contour", ...) %>% # This adds a legend
add_trace(..., type = "contour", ...) %>% # This adds another unwanted legend
add_trace(..., type = "contour", ...) %>% # This adds yet another unwanted legend
...
add_trace(..., type = contour", ...) # Now I have dozens of legends that I don't want!
I'm using Plotly for R, not Plotly for Python.
The legend can be hidden like:
p <- plot_ly(mtcars, x = ~wt, y = ~cyl, z = ~mpg, type = "contour")
p %>% hide_colorbar()