繁体   English   中英

共享轴极坐标子图,使用plotly

[英]Shared axis polar subplots using plotly

我正在使用子图绘制不同的散点图。 但是我希望它们都具有相同的范围[0,1]。 我试过使用radialaxis和update_layout。 但是,只有第一个子图会更改。 有没有办法修改所有子图?

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但我们会很快:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM