How to update_layout to both Barpolar subplots

Hello,

I am plotting two Barpolar subplots in one figure using the code below (please ignore the actual data variables’ names).

fig = plotly.subplots.make_subplots(rows=1, cols=2,
                                        specs=[[{'type': 'polar'}]*2],
                                        subplot_titles=[
                                                        'Non-equivariant',
                                                        'Trans-equivariant',
                                                        ],)

    # non-equivariant plot
    fig.add_trace(go.Barpolar(r=translations.ravel(),
                                theta=rotations.ravel(),
                                marker={
                                            "colorscale": plotly.colors.sequential.Viridis,
                                            "showscale": True,
                                            "color": non_eqv_gen_accuracy.transpose().ravel(),
                                            "line_color": None,
                                            "line_width": 0,
                                        },
                                customdata=non_eqv_custom_data,
                                name = 'Non-eqv accuracy'),
                    row=1, col=1)

    # equivariant plot
    fig.add_trace(go.Barpolar(r=translations.ravel(),
                                theta=rotations.ravel(),
                                marker={
                                            "colorscale": plotly.colors.sequential.Viridis,
                                            "showscale": False,
                                            "color": trans_eqv_gen_accuracy.transpose().ravel(),
                                            "line_color": None,
                                            "line_width": 0,
                                        },
                                customdata=trans_eqv_custom_data,
                                name = 'Trans-eqv accuracy'),
                    row=1, col=2)

Since I want to remove the gap between the bars in this polar bar plot, I added

fig.update_layout(polar_bargap=0)

at the end of my script. However, only the first (row1, col1) Barpolar subplot gets all the gaps removed, the second one keeps unchanged. May I know what should I do to make this update_layout work on both subplots? Thank you very much in advance!

Hi @dlzzk,

When you are plotting polar charts, plotly uses go.layout.Polar (print help(go.layout.Polar) to see the properties of such a layout. To update the common polar layout parameters in all subplots, use fig.update_polars, instead of fig.update_layout:

fig.update_polars(bargap=0)

But if you print(fig.layout) you see two annotations, for subplot titles. They are not included as polar settings and to update titles for all subplots, the shortest path is as follows:

for annot in fig.layout.annotations:
    annot['font']['size']=14
    annot['y']=1.1