matplotlib

shared subplot axes


In [65]:
import matplotlib.pyplot as plt
import numpy as np

N = 2

np.random.seed(123)
f, axes = plt.subplots(N, N, sharex=True, sharey=True)
ax = f.add_subplot(1, 1, 1, frameon=False)
ax.set_xlim([-3, 3])
ax.set_ylim([-3, 3])
# ax.set_xlabel('my x label')

plt.xlabel("common X")
for i in range(N):
    for j in range(N):
        ax = axes[i][j]
#         ax.set_ylim(ax.get_ylim()[::-1])
        img = np.random.randn(10, 10).astype(np.float32)
        img = np.flipud(img)
        ax.pcolor(img)
#         plt.gca().invert_yaxis()
        ax.tick_params(labelcolor='none', top='off', bottom='off', left='off', right='off')
#         ax.set_ylim(ax.get_ylim()[::-1])
#         ax.invert_yaxis()

# f.subplots_adjust(hspace=0, wspace=0)
plt.show()