-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlotting.py
70 lines (56 loc) · 1.76 KB
/
Plotting.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
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
import PyQt5.QtWidgets as QtWidgets
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
"""
TODO:
-
"""
class PlotWidget(QtWidgets.QWidget):
"""Widget for PyQt5 with the plot
...
Parameters
----------
x: list
List with the x values
y: list
List with the y values
z: list
List with the z values
colors: tuple
Tuple with the RGB colors
alpha: float
The transparency of the plot
...
Attributes
----------
fig: matplotlib.figure
axes: matplotlib.axes
canvas: matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg
"""
def __init__(self):
super().__init__()
self.fig = Figure() # Create a matplotlib figure
self.canvas = FigureCanvas(self.fig) # Get the plot image
self.axes = self.fig.add_subplot(111,projection='3d') # Create matpotlib axes
self.setWindowTitle('Linear transformations')
self.layout = QtWidgets.QGridLayout(self) # Set the layout
self.addToLayout(self.canvas, [0,0],[10,10]) # add the plot to the layout
def scatter(self,xyzgrid:list,colors:list):
"""Scatter the data
...
Parameters
----------
xyzgrid:list
data for plotting
xyzgrid[0] the x data
xyzgrid[1] the y data
xyzgrid[2] the z
colors:list
colors
"""
self.axes.clear()
self.axes.scatter(xyzgrid[0],xyzgrid[1],xyzgrid[2],c = colors,alpha=0.7)
def addToLayout(self, widget, position:list = [0,0], size:list = [1,1]):
"""Add widget to layout
"""
self.layout.addWidget(widget,position[1],position[0],size[1],size[0])