PyQtGraph – Scatter Plot Graph
In this article we will see how we can create a scatter plot graph using PyQtGraph module. PyQtGraph is a graphics and user interface Python library for functionalities commonly required in designing and science applications. Its provides fast, interactive graphics for displaying data (plots, video, etc.). A scatter plot uses dots to represent values for two different numeric variables. It is a type of plot that uses Cartesian coordinates to display values for typically two variables for a set of data. The position of each dot on the horizontal and vertical axis indicates values for an individual data point. Scatter plots are used to observe relationships between variables.
We can create a plot window and create scatter plot graph on it with the help of commands given below
# creating a pyqtgraph plot window plt = pg.plot() # creating a scatter plot graphof size = 10 scatter = pg.ScatterPlotItem(size=10)
In order to create a scatter plot graph in pyqtgraph, following steps needs to be followed:
- Import the pyqtgraph module
- import other modules as well like numpy and pyqt5
- Create a main window class
- Create scatter plot item
- Create random spots at random position using numpy
- Add those spots to the scatter plot data
- Create a grid layout
- Add scatter plot and additional label to the layout
- Set layout widget as the central widget
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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course