Black Lives Matter. Please consider donating to Black Girls Code today.

Two Y-Axes Alignment


I’ve been working on a Two Y-Axes plot and I’m having a few issues manually aligning the two axes. The bar plot is referenced to the primary axis and the line plot is referenced to the secondary axis.

  1. From the chart above, is it possible to align y=0 (primary axis) with y2=50 (secondary axis) from the line plot? I’ve been playing around for most of the day but not really getting anywhere. I can get the axes to almost line up setting a manual range, but it’s not correct.

  2. In addition to this, is there a feature that would allow me to fill the area between the line plot and y1=0 of the primary axis? I initially used the fill attribute on yaxis2, but this fills to the zero line of the same axis, which isn’t what I’m looking to achieve. Is it possible to impose an imaginary zero-line on the secondary axis and fill to this?

Hopefully this makes sense. Please let me know how I can improve my question formatting for future posts.

Thank you.