How to adjust Plotly legend/colorbar background transparency/colour

Question:

I’m trying to edit the appearance of a map I have made, but if I choose to have the colorbar/legend visible, it sits on a white background:

enter image description here

This white is a bit jarring for the rest of the color scheme. At the moment, I’m just hiding the whole thing with:

fig.update_coloraxes(showscale=False)

But that obviously makes the map harder to understand, so is there a way I can still show the bar either with a darker background or without a background?

Asked By: Vintagefiretruk

||

Answers:

You can use the attribute bgcolor of colorbar:

color = ... # your color
fig.update_coloraxes(colorbar=dict(bgcolor=color))
Answered By: rftr
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.