PyQtGraph – Error Bar Graph
In this article we will see how we can create a error bar graph in the PyQtGraph module. PyQtGraph is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications. Its primary goals are to provide fast, interactive graphics for displaying data (plots, video, etc.). Error bars are graphical representations of the variability of data and used on graphs to indicate the error or uncertainty in a reported measurement. They give a general idea of how precise a measurement is, or conversely, how far from the reported value the true value might be.
We can create a plot window and create error bar graph on it with the help of commands given below.
# creating a pyqtgraph plot window plt = pg.plot() # creating a error bar item object error = pg.ErrorBarItem(x=x, y=y, top=top, bottom=bottom, beam=0.5)
In order to create a error bar graph in pyqtgraph we have to do the following
1. Import the pyqtgraph module
2. import other modules as well like numpy and pyqt5
3. Create a main window class
4. Create a plot window and error bar item
5. Set x-axis, y-axis and upper and lower error values to the error bar item
6. Create a grid layout
7. Add error bar item to the plot window and plot the data on plot window
8. Add plot window and additional label to the layout
9. Set layout widget as the central widget
Below is the implementation
Please Login to comment...