PyQtGraph – Creating Graph Item
In this article we will see how we can create a graph item in PyQTGraph. 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.). A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph. Graph consists of a finite set of vertices(or nodes) and set of Edges which connect a pair of nodes.
We can create a graphic layout widget with the help of command given below
# creating graphics layout widget win = pg.GraphicsLayoutWidget()
In order to plot the video we have to do the following
- Import the pyqtgraph, pyqt5 and numpy module.
- Create a main window class.
- Create a graphic layout widget and add image view box to it.
- Create a graph item and add it to the view box.
- Set the positions of nodes and edges i.e connections and set symbols to them.
- Create a grid layout and add the graphic layout window to it with other widgets and set the grid widget as central widget of main window.
Below is the implementation.