Hiding Color Scale / Color Legend

If anyone comes across this issue and wants a work around I came up with a janky solution that works.

  1. Manually create a vector of colors that corresponds with the data. This function will do that:

spectral_color ← function(vector) {
vector ← df$variable
df ← cbind.data.frame(vector, seq=seq(1:length(vector)))
df ← arrange(df, vector)
df$pallete ← colorRampPalette(brewer.pal(11,“Spectral”))(length(vector))
df ← arrange(df, seq)
return(df$pallete)
}

  1. Define the color in the “marker parameter” so it looks like something below:

bubble ← plot_ly(df, x=var1, y=var2, mode = “markers”, marker = list(size = (abs(var3)*40)+8, color=spectral_color(var3)),
hoverinfo = “text”, text=paste(gsub(‘(.{1,90})(\s|$)’, ‘\1
’, df$var4)), showlegend=FALSE, showscale=FALSE)

With this you can color the plot without a legend / color scale appearing.

1 Like