-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyplotwidget.py
More file actions
91 lines (69 loc) · 2.86 KB
/
myplotwidget.py
File metadata and controls
91 lines (69 loc) · 2.86 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from PyQt5 import QtWidgets, QtGui, QtCore
import pyqtgraph as pg
import numpy as np
class myplotwidget (pg.PlotWidget) :
def __init__(self, parent):
pg.setConfigOption('background', (90,90,90))
pg.PlotWidget.__init__(self, parent)
legend = self.addLegend()
legend.setBrush('k')
self.setLabel('bottom',"YEAR")
self.setLabel('left', "VALUE")
self.setLabel('top',"PyMODISView Time Series Plot")
self.pen0 = pg.mkPen('r', width=1.5)
self.pen1 = pg.mkPen('g', width=1.5)
self.pen0_dot = pg.mkPen('r', width=1., style=QtCore.Qt.DotLine)
self.pen1_dot = pg.mkPen('g', width=1., style=QtCore.Qt.DotLine)
self.xmin = 2000
self.xmax = 2025
self.plottype = 0 # 0 for LST, 1 for NDVI
x = np.arange (0,10)+2000
y = np.arange (0,10)*4.
#self.plot(x, y, pen='y', title='Test Plot')
def set_plottype (self, thistype) :
self.plottype = thistype
def set_y (self, yvals):
self.clear()
npts = yvals[0].size
x = np.arange(npts) + 2000
if (self.plottype==0) :
self.plot(x,yvals[0],pen=self.pen0, name="LST_Night")
self.plot(x,yvals[1],pen=self.pen1, name="LST_DAY")
else :
self.plot(x, yvals[0], pen=self.pen0, name="NDVI")
self.plot(x, yvals[1], pen=self.pen1, name="EVI")
#self.plot(x,yvals[0],QtGui.QPen(QtCore.Qt.red))
#self.plot(x,yvals[1],QtGui.QPen(QtCore.Qt.yellow))
def set_xy (self, xvals, yvals) :
self.clear()
#self.addLegend()
if (self.plottype==0) :
self.plot(xvals,yvals[0],pen=self.pen0, name="LST_Night")
self.plot(xvals,yvals[1],pen=self.pen1, name="LST_DAY")
else :
self.plot(xvals, yvals[0], pen=self.pen0, name="NDVI")
self.plot(xvals, yvals[1], pen=self.pen1, name="EVI")
self.xmin = np.min(xvals)
self.xmax = np.max(xvals)
def add_meanvalues (self, mean0, mean1):
xnew = [self.xmin, self.xmax]
y0 = [mean0, mean0]
y1 = [mean1, mean1]
self.plot(xnew, y0, pen=self.pen0_dot)
self.plot(xnew, y1, pen=self.pen1_dot)
# self.plot(x,yvals[0],QtGui.QPen(QtCore.Qt.red))
# self.plot(x,yvals[1],QtGui.QPen(QtCore.Qt.yellow))
def plot_data (self, x, y):
self.plot(x,y)
def set_plot_data (self, xarr, yarr):
self.xarr = xarr
self.yarr = yarr
def add_points(self, year, val0, val1):
#self.clear()
xvals = [2000,year]
yvals = [val0, val1]
#self.addPoints(xvals,yvals,symbol='t1')
#self.plot(xvals,yvals,pen=self.pen0)
self.plot([year,], [val0,], pen=self.pen0, symbol='t1', symbolSize=10)
self.plot([year, ], [val1, ], pen=self.pen1, symbol='t1', symbolSize=10)
#self.plot([year], [val1], symbol='o')