import matplotlib.pyplot as plt
plt.figure()
plt.xlabel('x')
plt.ylabel('y')
plt.plot([0,1],[1,0])
plt.show()
我希望能够只调整绘图本身,而不是整个窗口,而无需实际调整大小。例如,我希望x轴只是当前的0.75倍,而y轴只有0.5倍长。请记住,我只是谈论绘制的部分本身,而不是整个窗口。但是如何?
答案 0 :(得分:0)
如果我理解你的问题,那么你要找的是matplotlib模块中的GridSpec函数。
你可以使用:
import matplotlib.pyplot as plt
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)
plt.figure(0)
ax1 = plt.subplot2grid((3,3), (0,0), colspan=3)
ax2 = plt.subplot2grid((3,3), (1,0), colspan=2)
ax3 = plt.subplot2grid((3,3), (1, 2), rowspan=2)
ax4 = plt.subplot2grid((3,3), (2, 0))
ax5 = plt.subplot2grid((3,3), (2, 1))
plt.suptitle("subplot2grid")
make_ticklabels_invisible(plt.gcf())
plt.show()
将返回以下示例:
有关详细信息,请访问this link