Shown in red is the default behavior of twinx() . An additional modification of example applies to what is shown in green.
You can change both new axes, similar to green one, but select the left spine and apply a negative offset. Therefore, add / modify the example with:
par1.spines["left"].set_position(("axes", -0.4)) # red one par2.spines["left"].set_position(("axes", -0.2)) # green one make_patch_spines_invisible(par1) make_patch_spines_invisible(par2) par1.spines["left"].set_visible(True) par1.yaxis.set_label_position('left') par1.yaxis.set_ticks_position('left') par2.spines["left"].set_visible(True) par2.yaxis.set_label_position('left') par2.yaxis.set_ticks_position('left')

zorder from the lines is only taken into account in the axes (or does it appear so?), since you have separate axes one above the other, you have to change the zorder axes:
host.set_zorder(1) par1.set_zorder(2) par2.set_zorder(3)
Note that host has a white background, so placing it on top will hide other lines unless you set a transparent background.
Rutger Kassies Nov 22 '13 at 14:21 2013-11-22 14:21
source share