-
Notifications
You must be signed in to change notification settings - Fork 92
/
SimplePlot.py
51 lines (33 loc) · 1.38 KB
/
SimplePlot.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
# https://github.com/stevenlovegrove/Pangolin/blob/master/examples/SimplePlot
import OpenGL.GL as gl
import pangolin
import numpy as np
def main():
# Create OpenGL window in single line
pangolin.CreateWindowAndBind('Main', 640, 480)
# Data logger object
log = pangolin.DataLog()
# Optionally add named labels
labels = ['sin(t)', 'cos(t)', 'sin(t)+cos(t)']
log.SetLabels(labels)
# OpenGL 'view' of data. We might have many views of the same data.
tinc = 0.03
plotter = pangolin.Plotter(log, 0.0, 4.0*np.pi/tinc, -2.0, 2.0, np.pi/(4*tinc), 0.5)
plotter.SetBounds(0.0, 1.0, 0.0, 1.0)
plotter.Track('$i')
# Add some sample annotations to the plot
plotter.AddMarker(pangolin.Marker.Vertical, -1000, pangolin.Marker.LessThan,
pangolin.Colour.Blue().WithAlpha(0.2))
plotter.AddMarker(pangolin.Marker.Horizontal, 100, pangolin.Marker.GreaterThan,
pangolin.Colour.Red().WithAlpha(0.2))
plotter.AddMarker(pangolin.Marker.Horizontal, 10, pangolin.Marker.Equal,
pangolin.Colour.Green().WithAlpha(0.2))
pangolin.DisplayBase().AddDisplay(plotter)
t = 0
while not pangolin.ShouldQuit():
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
log.Log(np.sin(t), np.cos(t), np.sin(t)+np.cos(t))
t += tinc
pangolin.FinishFrame()
if __name__ == '__main__':
main()