#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Franek Łazarewicz-Muradyan" __copyright__ = "Copyright 2021, Franek Łazarewicz-Muradyan" __version__ = "0.1" __status__ = "Beta" __email__ = "uinarf@autistici.org" from PyQt5 import QtWidgets from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as \ NavigationToolbar from matplotlib.figure import Figure from matplotlib import gridspec #matplotlib.use('QT5Agg') class MplCanvas(FigureCanvas): def __init__(self): self.fig = Figure(tight_layout=True) grid = gridspec.GridSpec(ncols=32, nrows=3) self.ax = self.fig.add_subplot(grid[0, 0:32]) self.ax_1 = self.fig.add_subplot(grid[1, 0:32], sharex=self.ax) self.ax_2 = self.fig.add_subplot(grid[2, 0:32], sharex=self.ax) self.fig.align_labels() FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) class MplWidget(QtWidgets.QWidget): def __init__(self, parent = None): QtWidgets.QWidget.__init__(self, parent) self.canvas = MplCanvas() self.toolbar = NavigationToolbar(self.canvas, self) self.vbl = QtWidgets.QVBoxLayout() self.vbl.addWidget(self.toolbar) self.vbl.addWidget(self.canvas) self.setLayout(self.vbl)