python – tight_layout() doesn’t work with changing tick labels


I am attempting to switch between a linear and logit scaling in my PyQt graph widget.

    from matplotlib import pyplot
    class GraphWidget(QWidget):
        rightClickEvent = QtCore.pyqtSignal()
        def __init__(self, parent=None):
            QWidget.__init__(self, parent=parent)
            self.parent = parent
            self.figure, self.axes = pyplot.subplots()
            pyplot.grid(b=True, which='major', color='#666666', linestyle='-')
            self.menu = QtGui.QMenu(self)
            self.build_menu()
            self.rightClickEvent.connect(self.show_menu) # There is an edit button in the menu
            self.figure.tight_layout()
        def edit(self): # Gets called when the "edit" button in the menu is triggered
            FigureOptions.figure_edit(self.axes, self)
            pyplot.tight_layout()

When I switch, it goes from a normal notation to scientific notation (e.g. 1 – 10^3). When this changes the y-axis, the tick label will be cut off by the left edge of the application window. However, when I open and close the figure edit menu a second time, the layout changes to include the logit tick labels. This is because of where I’m calling tight_layout() or does the appear of the figure change only when plot() is called?