blob: cc136009b4c09575bd5587d0292d888a6f2c85ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/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)
|