In this article we will see how we can create 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.) and second is to provide tools to aid in rapid application development (for example, property trees such as used in Qt Designer).
A bar graph is a method for visualizing a set of data. Simple bar graphs compare data with one independent variable and can relate to a set point or range of data. Complex bar graphs compare data with two independent variables. Either type of graph can be oriented horizontally or vertically. Bar graph is created with the help of BarGraphItem class in PyQtGraph.
In order to plot the bar graph in PyQtGraph we have to do the following
1. Importing the PyQtgraph module
2. Creating a plot window
3. Create or get the plotting data i.e horizontal and vertical data
4. Create a BarGraphItem object to plot the bar graph between the data
5. Append the BarGraphItem object to the plot window
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.