I'm plotting different Scatterpolar charts using subplots. Yet I want them to all have the same range [0,1]. I've tried using radialaxis and update_layout. However only the first of the subplots changes. Is there a way I can modify all subplots?
lst = range(1,rows+1)
n_rows = list(itertools.chain.from_iterable(itertools.repeat(x, cols) for x in lst))
df_grouped = df.groupby('cluster').mean()
fig = make_subplots(rows=rows, cols=cols, specs=[[{'type': 'polar'}]*cols]*rows,
horizontal_spacing=0.05, vertical_spacing=0.06)
for col, (row, index) in enumerate(zip(n_rows, df_grouped.index.values)):
fig.add_trace( go.Scatterpolar(name="Cluster "+str(int(index)),
r=df_grouped.loc[df_grouped.index == index].values[0],
theta=df_grouped.columns.values),
row, col%cols+1)
fig.update_traces(fill='toself')
fig.update_layout(polar=dict(radialaxis=dict(range=[0, 1])),
legend=dict(x=0.20,y=1.15), legend_orientation="h",
height=800, width=900,
margin=dict(l=5, r=5, t=5, b=5) )
p = plot(fig, output_type='div')
displayHTML(p)
Thanks in advance.
Yes: each polar subplot has its own key in layout
so you’ll want to do something like update_layout(polar=dict(...), polar2=dict(...), polar3=dict(...), ...)
We don’t yet have a single function to batch update all polar
s like we do for update_xaxes
but we will soon :)