我在PyQt5widget
中的QVBoxLayout
中有一个matplotlib.pyplot
对象。沿边缘有一些很小的空间,真的很烦人。如何删除它?在
请参见下面的屏幕截图。
我已经试过setlayoutSpacing(0)
,但没有效果。在
下面是breviate代码(删去许多数据处理代码):
class MpWidget_SCF(Qt.QWidget):
def __init__(self, parent=None, y=[]):
super(MpWidget_SCF, self).__init__()
self.setParent(parent)
self.dpi = 50
self.fig = MpPyplot.figure(figsize=(2, 2), dpi=self.dpi, )
self.SCF_subplot = MpPyplot.subplot(1, 1, 1)
self.canvas = MpFigureCanvas(self.fig)
self.canvas.setParent(self)
self.SCF_subplot.clear()
self.SCF_subplot.plot(range(len(y)), y, 'r')
self.canvas.draw()
self.vLayout = Qt.QVBoxLayout()
self.vLayout.addWidget(self.canvas)
self.vLayout.setSpacing(0)
self.setLayout(self.vLayout)
class myWidget(Qt.QWidget):
def __init__(self):
super(myWidget, self).__init__()
self.main = Ui_OutputWindow_Form()
self.main.setupUi(self)
self.main.SCF_Graphic_Widget = MpWidget_SCF(self)
self.main.verticalLayout_2.addWidget(self.main.SCF_Graphic_Widget)
self.show()
您可以删除default margins:
相关问题 更多 >
编程相关推荐