My goal is to have a plot with a transparent background exactly on top of another plot, but with the y-axis on the other side. However, I do not know how to get the size right.
This code
plt.figure(1, figsize=(9, 3))
plt.subplot(1,1,1)
plt.plot([1, 2], [3, 2], color='black')
ax2 = plt.axes([0, 0, 1, 1], facecolor='none')
ax2.yaxis.set_label_position("right")
ax2.yaxis.tick_right()
ax2.plot([1, 2], [3.1,2.1])
produces
So apparently, the size of the box needs to be set differently.
In case you are wondering why, here is the backdrop. My goal is to have a plot with 2 y-axes, one on the left and one on the right, where the left y-axis is interrupted and the right one is not. With interrupted I mean like this:
The figure is created with 2 subplots like this:
top_ratio = 1
bot_ratio = 4
gsdict={'height_ratios':[top_ratio, bot_ratio]}
f, (ax1, ax2) = plt.subplots(2, 1, sharex=True, gridspec_kw=gsdict)
However, if I now use twinx to get another y-axis, that new y-axis is only for one of the subplots, but I want it to go all the way from top to bottom. My idea is to create an additional axis with transparent background and add it on top.