ここに投稿されたものと同様の問題があります。sharex
違いは、属性と属性を介して軸を共有する2つのサブプロットをプロットすると、プロット領域内に不要な空白ができることsharey
です。設定後も空白が残りますautoscale(False)
。たとえば、上記の投稿への回答と同様のコードを使用します。
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(2, 1, 1)
ax.imshow(np.random.random((10,10)))
ax.autoscale(False)
ax2 = fig.add_subplot(2, 1, 2, sharex=ax, sharey=ax) # adding sharex and sharey
ax2.imshow(np.random.random((10,10)))
ax2.autoscale(False)
plt.show()
この画像になります。
私も試してみax.set_xlim(0, 10)
ましたが、ここax.set_xbound(0, 10)
での提案に従って、役に立ちませんでした。余分な空白を取り除くにはどうすればよいですか?任意のアイデアをいただければ幸いです。