【发布时间】:2013-02-25 22:03:21
【问题描述】:
我有一个与here 发布的问题类似的问题。不同之处在于,当我绘制两个通过sharex 和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()
产生this 图像。
我也按照here的建议尝试了ax.set_xlim(0, 10)和ax.set_xbound(0, 10),但无济于事。我怎样才能摆脱多余的空白?任何想法将不胜感激。
【问题讨论】:
标签: python matplotlib whitespace