Add really basic GLGraphItem example
This commit is contained in:
parent
c3dba791d1
commit
13ab4de209
47
examples/GLGraphItem.py
Normal file
47
examples/GLGraphItem.py
Normal file
@ -0,0 +1,47 @@
|
||||
"""
|
||||
Demonstrates use of GLGraphItem
|
||||
|
||||
"""
|
||||
|
||||
## Add path to library (just for examples; you do not need this)
|
||||
import initExample
|
||||
|
||||
import pyqtgraph as pg
|
||||
import pyqtgraph.opengl as gl
|
||||
import numpy as np
|
||||
|
||||
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()
|
Loading…
Reference in New Issue
Block a user