CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
GraphItem.py58 linesDownload Raw Back to examples
1"""2Simple example of GraphItem use.3"""4 5import numpy as np6 7import pyqtgraph as pg8 9# Enable antialiasing for prettier plots10pg.setConfigOptions(antialias=True)11 12w = pg.GraphicsLayoutWidget(show=True)13w.setWindowTitle('pyqtgraph example: GraphItem')14v = w.addViewBox()15v.setAspectLocked()16 17g = pg.GraphItem()18v.addItem(g)19 20## Define positions of nodes21pos = np.array([22    [0,0],23    [10,0],24    [0,10],25    [10,10],26    [5,5],27    [15,5]28    ])29    30## Define the set of connections in the graph31adj = np.array([32    [0,1],33    [1,3],34    [3,2],35    [2,0],36    [1,5],37    [3,5],38    ])39    40## Define the symbol to use for each node (this is optional)41symbols = ['o','o','o','o','t','+']42 43## Define the line style for each connection (this is optional)44lines = np.array([45    (255,0,0,255,1),46    (255,0,255,255,2),47    (255,0,255,255,3),48    (255,255,0,255,2),49    (255,0,0,255,1),50    (255,255,255,255,4),51    ], dtype=[('red',np.ubyte),('green',np.ubyte),('blue',np.ubyte),('alpha',np.ubyte),('width',float)])52 53## Update the graph54g.setData(pos=pos, adj=adj, pen=lines, size=1, symbol=symbols, pxMode=False)55 56if __name__ == '__main__':57    pg.exec()58 
Aluode/PerceptionLabPortable · CoolFace