Is there a go.Barpolar colorbar?


I am trying to plot a Barpolar() plot with a colorbar next to it.
Does Barpolar() offer such a feature? - I can’t figure it out from the documentation.

One alternative I found was px.bar_polar().

Thanks a lot for your help,

Yes, there is a colorbar, but it is a a marker property , used when the marker color is an array of values to be mapped onto a colorscale:

import numpy as np
import plotly.graph_objects as go
r, theta = np.meshgrid(np.linspace(0, 1, 10), np.linspace(0, 360, 18))

fig = go.Figure(go.Barpolar(
    r= r.flatten(),
    marker_color=(r.flatten())**2-0.2, #marker_color is a function of radius
    marker_colorscale="viridis", marker_colorbar_thickness=24,
    marker_cmin=0, marker_cmax=1))
fig.update_layout(width=500, height=500)


or marker_color is an array of values independent on r and theta:

theta=np.linspace(0, 360, 18)
r= np.ones(theta.shape)
fig = go.Figure(go.Barpolar(
    r= r.flatten(),
    marker_color=np.random.rand(18),   ,
    marker_colorscale="ice", marker_colorbar_thickness=24,
fig.update_layout(width=500, height=500)


Thanks a lot for your help empet! I am still struggling a bit to read the docs but that’s because I am new I guess. :slightly_smiling_face:
I saw that there was the class plotly.graph_objects.barpolar.Marker and that it has an argument colorbar=None but I didn’t know how to access it when creating the figure with
fig = go.Figure(go.Barpolar(…)

I kept typing a dot instead of an underscore between “marker” and its property “colorbar”.
Something like this “marker.colorbar.bgcolor = ‘crimson’” instead of “marker_colorbar_bgcolor = ‘crimson’”.

Thanks so much and have a nice weekend!