I’m plotting data stored in a Pandas dataframe as a Matplotlib graph with a Matplotlib toolbar, as explained in chapter 36 of the PySide2 book.
The toolbar’s controls appear to have the same height as a QPushButton. Despite that, they appear really large compared to the rest of the interface, perhaps also because of their stronger black color. Is there any way to make them, say, the same height as a default line of text for instance?
Ideally I’d love to see them as a semi-transparent overlay on the graph’s canvas itself, as they do in recent versions of MATLAB. But I haven’t found any hint in the Matplotlib documentation that this might be possible.
Here is my current implementation of the graph in the following window:
import matplotlib # PySide2 imports done before matplotlib's from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar from matplotlib.figure import Figure matplotlib.use("Qt5Agg") class PlotterWidget(QWidget): def __init__(self): super().__init__() # Create three "plot" QPushButton widgets # Create a maptlotlib FigureCanvas object, # which defines a single set of axes as its axes attribute self.canvas = MplCanvas(self, width=5, height=3, dpi=100) # Create toolbar for the figure: # * First argument: the canvas that the toolbar must control # * Second argument: the toolbar's parent (self, the PlotterWidget) toolbar = NavigationToolbar(self.canvas, self) # Define and apply widget layout layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addLayout(<sublayout of three "plot" QPushButton here>) layout.addWidget(toolbar) layout.addWidget(self.canvas) self.setLayout(layout) # def slot methods for the three "plot" QPushButtons