Algin multiple y-achse on Plotly

Hi @hamoudie12

You can do it using the following steps:

You can do it like this:

  1. Set (or find) appropriate minimum and maximum values for your y-axis,

  2. adjust your y ranges using fig.update_layout(yaxis=dict(range=[all_min,all_max]), yaxis2=dict(range=[all_min,all_max])) , and

  3. set the scaleanchor of your secondary y-axis to y1 like this: fig.update_layout(yaxis2=dict(scaleanchor = 'y1'))

If the source of your figure data is a pandas DataFrame, there are more elegant ways of finding global max and min values than just hard-coding them in there.

Check out other methods here:

2 Likes