Fig.update_layout only affecting first subplot

I’m trying to have multiple subplots with no grid-lines on the yaxis. It seems like whatever I pass in to fig.update_layout is only affecting my first subplot.

fig = make_subplots(rows=1, cols=2)

fig.add_trace(
    go.Scatter(
        x=list(range(sample_points)),
        y=data_gx.iloc[scene],
        name='X-axis',
        line=dict(color='green', width=2)
    ),
    row=1, col=1
)

fig.add_trace(
    go.Scatter(
        x=list(range(sample_points)),
        y=data_ax.iloc[scene],
        name='X-axis',
        line=dict(color='green', width=2)
    ),
    row=1, col=2
)

fig.update_layout(
    yaxis=dict(showgrid=False)
)

show

It’s because yaxis specifically refers to the first subplot, yaxis2 to the second etc. You can do

fig.update_layout(
    yaxis=dict(showgrid=False),
    yaxis2=dict(showgrid=False)
)

or alternatively, if you want to update all yaxes at the same time, use fig.update_yaxes:

fig.update_yaxes(showgrid=False)
1 Like
three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online