File: GLGraphItem.py

package info (click to toggle)
python-pyqtgraph 0.13.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,072 kB
  • sloc: python: 54,043; makefile: 127; ansic: 40; sh: 2
file content (44 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (3)
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
"""
Demonstrates use of GLGraphItem
"""

import numpy as np

import pyqtgraph as pg
import pyqtgraph.opengl as gl

app = pg.mkQApp("GLGraphItem Example")
w = gl.GLViewWidget()
w.setCameraPosition(distance=20)
w.show()

edges = np.array([
    [0, 2],
    [0, 3],
    [1, 2],
    [1, 3],
    [2, 3]
])

nodes = np.array(
    [
        [0, 0, 0],
        [1, 0, 0],
        [0, 1, 0],
        [1, 1, 1]
    ]
)

edgeColor=pg.glColor("w")

gi = gl.GLGraphItem(
    edges=edges,
    nodePositions=nodes,
    edgeWidth=1.,
    nodeSize=10.
)

w.addItem(gi)

if __name__ == "__main__":
    pg.exec()