forked from DSP-Projects/SamplingStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.py
More file actions
54 lines (39 loc) · 1.82 KB
/
Copy pathGraph.py
File metadata and controls
54 lines (39 loc) · 1.82 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore
from PyQt5.QtWidgets import QVBoxLayout, QWidget
class Graph:
def __init__(self, graphWidget, title, xlabel, ylabel):
self.title = title
self.graphWidget = graphWidget
# Ensure the parent widget has a layout
if graphWidget.layout() is None:
layout = QVBoxLayout(graphWidget)
graphWidget.setLayout(layout)
else:
layout = graphWidget.layout()
layout.addWidget(self.graphWidget)
# Set background and grid
self.graphWidget.setBackground('#0c202a')
# Configure plot labels and axis colors
self.graphWidget.getAxis('left').setPen(pg.mkPen(color='w', width=2))
self.graphWidget.getAxis('bottom').setPen(pg.mkPen(color='w', width=2))
self.graphWidget.getAxis('left').setTextPen(pg.mkPen(color='w'))
self.graphWidget.getAxis('bottom').setTextPen(pg.mkPen(color='w'))
# Label axes with color and size
self.graphWidget.setLabel('left', ylabel, **{'color': '#ffffff', 'font-size': '10pt'})
self.graphWidget.setLabel('bottom', xlabel, **{'color': '#ffffff', 'font-size': '10pt'})
#self.graphWidget.setXRange(1, 20, padding=0)
self.signal_plot = self.graphWidget.plot()
self.signal_x = []
self.signal_y = []
# Disable panning
# self.graphWidget.setMouseEnabled(x=False, y=False)
def set_signal(self, signal_x, signal_y):
self.clear_signal()
self.signal_x = signal_x
self.signal_y = signal_y
self.graphWidget.plot(self.signal_x, self.signal_y, pen='#3286ad')
def clear_signal(self):
self.graphWidget.clear()
self.signal_x = []
self.signal_y = []