[Matplotlib-users] Share second y-axis

Florian Lindner mailinglists at xgm.de
Mon Jan 30 05:06:31 EST 2017


Hello,

I create a 2x2 grid of subplots:

f, sp = plt.subplots(2, 2, sharex='col', sharey='row')
sp_lin = [ sp[0][0], sp[0][1], sp[1][0], sp[1][1] ]

with two y-axis each

ax1 = sp_lin[i]
ax1.semilogy(...)
ax1.set_ylabel("RMSE")

ax2 = ax1.twinx()
ax2.semilogy(...)
ax2.set_ylabel("Condition")

ax1.set_xlabel("m")


The x-axis (m) is shared just nicely, as well as the first y-axis (RMSE). But the second y-axis (Condition) is not shared.

How can I make it being shared as well?

1 2
3 4

Only plots 1 and 3 have the RMSE axis on their left. I want that only plots 2 and 4 have the Condition axis on the right.

Thanks!
Florian



More information about the Matplotlib-users mailing list