Aluode/PerceptionLabPortable
0
1"""2Simple example using BarGraphItem3"""4 5import numpy as np6 7import pyqtgraph as pg8 9win = pg.plot()10win.setWindowTitle('pyqtgraph example: BarGraphItem')11 12x = np.arange(10)13y1 = np.sin(x)14y2 = 1.1 * np.sin(x+1)15y3 = 1.2 * np.sin(x+2)16 17bg1 = pg.BarGraphItem(x=x, height=y1, width=0.3, brush='r')18bg2 = pg.BarGraphItem(x=x+0.33, height=y2, width=0.3, brush='g')19bg3 = pg.BarGraphItem(x=x+0.66, height=y3, width=0.3, brush='b')20 21win.addItem(bg1)22win.addItem(bg2)23win.addItem(bg3)24 25 26# Final example shows how to handle mouse clicks:27class BarGraph(pg.BarGraphItem):28 def mouseClickEvent(self, event):29 print("clicked")30 31 32bg = BarGraph(x=x, y=y1*0.3+2, height=0.4+y1*0.2, width=0.8)33win.addItem(bg)34 35if __name__ == '__main__':36 pg.exec()37 