PyQtGraph – Setting Data of Error Bar Graph
In this article, we will see how we can set data of the 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. Data of the error bar graph is basically the x-axis & y-axis values and the upper and lower bounds of these values i.e error estimation.
We can create a plot window and create an 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 do this we use setData method with the error bar item object
Syntax : error.setData(x=x, y=y, top=top, bottom=bottom)
Argument : It takes four numpy arrays as argument
Return : It returns None
Below is the implementation.