There is a straightforward solution without messing with matplotlib: just pandas.
Tweaking the original example:
table = sql.read_frame(query,connection)
ax = table[0].plot(color=colors[0],ylim=(0,100))
ax2 = table[1].plot(secondary_y=True,color=colors[1], ax=ax)
ax.set_ylabel('Left axes label')
ax2.set_ylabel('Right axes label')
Basically, when the secondary_y=True
option is given (eventhough ax=ax
is passed too) pandas.plot
returns a different axes which we use to set the labels.
I know this was answered long ago, but I think this approach worths it.