我正在用子图绘制不同的散射极图。但我希望它们都具有相同的范围[0,1]。我试过使用radialaxis和更新布局。然而,只有第一个子地块发生了变化。有没有办法修改所有子地块
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)
提前谢谢
是:每个极性子图在
layout
中都有自己的键,因此您需要执行类似于update_layout(polar=dict(...), polar2=dict(...), polar3=dict(...), ...)
的操作我们还没有一个函数来批量更新所有的
polar
,就像我们对update_xaxes
所做的那样,但是我们很快就会做到:)相关问题 更多 >
编程相关推荐