I am trying to plot side-by-side two graphs made with px.bar_polar. My code is the following:
fig = px.bar_polar(df_obs_count, r="percent", theta="WDir",
color="WSpd (m/s)",
range_r=r_range,
color_discrete_sequence=px.colors.sequential.Rainbow)
fig.update_layout(title = segname+' Observed', margin=dict(t=30, b=30))
fig.show()
fig = px.bar_polar(df_mod_count, r="percent", theta="WDir",
color="WSpd (m/s)",
range_r=r_range,
color_discrete_sequence=px.colors.sequential.Rainbow)
fig.update_layout(title = segname+' Modelled', margin=dict(t=30, b=30))
fig.update_layout(template='plotly')
fig.show()
# create first wind rose plot
fig1 = px.bar_polar(df_obs_count, r="percent", theta="WDir",
color="WSpd (m/s)",
range_r=r_range,
color_discrete_sequence=px.colors.sequential.Rainbow)
fig1.update_layout(title=segname+' Observed', margin=dict(t=30, b=30))
# fig1.update_layout(template='plotly')
# create second wind rose plot
fig2 = px.bar_polar(df_mod_count, r="percent", theta="WDir",
color="WSpd (m/s)",
range_r=r_range,
color_discrete_sequence=px.colors.sequential.Rainbow)
fig2.update_layout(title=segname+' Modelled', margin=dict(t=30, b=30))
# fig2.update_layout(template='plotly')
# create subplot with shared legend
fig = make_subplots(rows=1, cols=2, subplot_titles=("Observed", "Modelled"), specs=[[{'type': 'polar'}, {'type': 'polar'}]])
fig.add_trace(fig1['data'][0], row=1, col=1)
fig.add_trace(fig1['data'][1], row=1, col=1)
fig.add_trace(fig2['data'][0], row=1, col=2)
fig.add_trace(fig2['data'][1], row=1, col=2)
# fig.update_layout(title=segname, template='custom_dark')
fig.show()
The first two figures are the two plots I want to put together. The third figure is an attempt to make that happen. My data looks like this:
WDir WSpd (m/s) freq percent
N 0-2 58 0.088189
N 2-4 119 0.180939
N 4-6 1838 2.794672
N 6-8 4095 6.226432
N 8-10 4838 7.356161
Does anyone know how I can make this plot?