How do you hide the color scale / color legend / color bar that appears to the right on a plot?
I thought one of these would do it, but neither worked: plot_ly(z = volcano, type = “surface”) %>% layout(showlegend = FALSE) plot_ly(z = volcano, type = “surface”) %>% layout(showscale = FALSE)
Lol interestingly enough that works on the minimum example above but not on my actual plots. Here is another example where hiding the legend and scale doesn’t actually hide it. I traced the issue down to having the color parameter. If you add color to a plot with mode=markers it seems plotly doesn’t want to hide the legend/scale/bar.
f1 <- list(
family = “Arial, sans-serif”,
size = 18,
color = “lightgrey”
)
f2 <- list(
family = “Old Standard TT, serif”,
size = 14,
color = “black”
)
a <- list(
title = “AXIS TITLE”,
titlefont = f1,
showticklabels = TRUE,
tickangle = 45,
tickfont = f2,
exponentformat = “e”,
showexponent = “All”
)
s <- seq(0, 8)
plot_ly(x = s, y = s, mode = “markers”, color = s, showlegend = FALSE, showscale = FALSE) %>%
add_trace(y = rev(s)) %>%
layout(xaxis = a, yaxis = a, showlegend = FALSE, showscale = FALSE)
In case anybody else comes across this problem (I was having issues turning off colorbars for a surface and a 3D scatter trace at the same time), add hide_colorbar():