✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Make_subplots with secondary y, 2 y-axis are not at the "same level"

For some reason, the 0 for y-axis on the left does not at the same level with the one on the right (my GREEN drawing)

Here is my code:

fig = make_subplots(specs=[[{'secondary_y': True}]])

fig.add_trace(go.Bar(name='US Daily Tests',
                     x=merged_df.date,
                     y=merged_df.totalTestResultsIncrease,
                     marker_color='darkblue',
                     opacity=0.3))

fig.add_trace(go.Bar(name='US Daily New Cases',
                     x=merged_df.date,
                     y=merged_df.new_cases,
                     marker_color='darkblue'))

fig.add_trace(go.Scatter(name='Positive Rate',
                     x=merged_df.date,
                     y=merged_df.positive_rate,
                     opacity=0.8,
                     marker_color='rgb(255, 127, 14)'),
             secondary_y="True")

fig.update_layout(
    title={
        'text': "COVID-19 Daily Numbers in United States",
        'x':0.1},
    barmode='overlay',
    plot_bgcolor='rgb(245,245,245)',
    legend=dict(
        x=0.02,
        y=0.95),
    margin=dict(l=0, r=0, b=0, t=50)
)

@tud7

This update will remove that issue:

fig.update_layout(yaxis2_range=[0, merged_df.positive_rate.max()+small_value]) 

Data in the column merged_df.positive_rate are positive?

Thanks. It works. Yes, all the values are positive. min value=0. Wondering why we have to do this