![](/img/trans.png)
[英]How to reduce margins in a matplotlib figure placed on a wxpython panel?
[英]How to set the margins for a matplotlib figure?
我正在生成一个有两个子图的屏幕图:一个是图像,另一个是图形。 图中的边距非常大。
如何调整数字周围的边距?
我搜索的大多数问题涉及保存图像(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)
看看plt.tight_layout()
或plt.subplots_adjust()
或fig.savefig(bbox_inches='tight')
。
与subplots_adjust
可以调整最参数,而tight_layout()
和bbox_inches='tight'
或多或少半自动。
您还可以使用plt.set(),其中包含adjust plot菜单中给出的属性,例如set(top = 0.82)等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.