如何设置matplotlib数字的边距?

Jes*_*ose 16 python matplotlib

我正在生成一个有两个子图的屏幕图:一个是图像,另一个是图形.图中的边距非常大.

如何调整数字周围的边距?


我搜索的大多数问题涉及保存图像(bbox看起来很完美),并使用轴而不是子图进行绝对定位.

这是我用来生成图形的代码:

def __init__(self, parent):
    wx.Panel.__init__(self, parent)
    ...

    self.figure, (self.picture, self.intensity) = \
        plt.subplots(nrows=2, figsize=(12, 5))
    self.figure.set_dpi(80)
    #self.figure.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1)
    #self.picture.imshow(np.random.uniform()) #size=(5, 50)))
    self.intensity.plot(np.random.random()) #size=641))

    self.intensity.autoscale(axis='x', tight=True)
Run Code Online (Sandbox Code Playgroud)

bmu*_*bmu 25

看看plt.tight_layout()plt.subplots_adjust()fig.savefig(bbox_inches='tight').

有了subplots_adjust你可以调整大多数参数,而tight_layout()bbox_inches='tight'或多或少半自动.