-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.py
36 lines (29 loc) · 1.12 KB
/
plotter.py
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
import pyqtgraph as pg
import pyqtgraph.exporters
import numpy as np
from pyqtgraph.Qt import QtGui, QtCore
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to PyQt, PyQt5, PySide or PySide2 (not implemented yet)
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
class PlotWidget(pg.GraphicsWindow):
def __init__(self, parent=None, **kargs):
pg.GraphicsWindow.__init__(self, **kargs)
self.setParent(parent)
self.setWindowTitle('')
# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)
self.p6 = self.addPlot(title="")
self.curve = self.p6.plot(pen='r')
def addData(self, xData, yData):
self.curve.setData(x = xData, y = yData)
def getImage(self, filename):
exporter = exporter = pyqtgraph.exporters.ImageExporter(self.scene())
exporter.export(filename)
if __name__ == '__main__':
w = PlotWidget()
w.show()
QtGui.QApplication.setStyleSheet(qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True))
QtGui.QApplication.instance().exec_()