Using overlay barmode with px.bar_polar()

So I’m having problems getting the polar bar chart to display the bars overlayed on top of each other.

I have very similar code to the example in the documentation so like this,

import plotly.express as px
df = px.data.wind()
fig = px.bar_polar(df, r="frequency", theta="direction",
                   color="strength", template="plotly_dark",
                   color_discrete_sequence= px.colors.sequential.Plasma_r, barmode = 'overlay')
fig.show()

This does not display bars drawn on top of each other. It works fine with px. bar(),

df = px.data.wind()
fig = px.bar(df, x="frequency", y="direction",
                   color="strength", template="plotly_dark",
                   color_discrete_sequence= px.colors.sequential.Plasma_r, barmode = 'overlay')
fig.show()

Any help would be appreciated!

fig = go.Figure()

fig.add_trace(go.Barpolar(
    
     r=[77.5*2, 72.5*2, 70.0*2,35, 22.5*2, 42.5*2, 40.0*2, 62.5*2],
    name='8-11 m/s',
    marker_color='rgb(158,154,200)'))
fig.add_trace(go.Barpolar(base=0,
   r=[57.5, 50.0, 45.0, 35.0, 20.0, 22.5, 37.5, 55.0],
    name='11-14 m/s',
    marker_color='rgb(106,81,163)'
))
    
fig.update_traces(text=['North', 'N-E', 'East', 'S-E', 'South', 'S-W', 'West', 'N-W'],)
fig.update_layout(
    #title='Wind Speed Distribution in Laurel, NE',
    font_size=16,
    legend_font_size=16,
    barmode='overlay',
    #polar_radialaxis_ticksuffix='%',
    #paper_bgcolor = "#000000",
    plot_bgcolor = "#000000",
    polar_angularaxis_rotation=90,
    polar=dict(radialaxis=dict(showticklabels=False), hole = 0.2, angularaxis=dict(showticklabels=False))),
fig.show()

This works for me. You can set the “base” attribute trace with greater value to zero and then add the trace with smaller value. and also set barmode to ‘overlay’ which you already know. A bit of attention to colors you get a radial barplot in overlay mode. Hope this helps.
PS: Ignore the legends.

Output:

1 Like