PyQtGraph Quick Tutorial #1
PyQtGraph is a package for creating 2D and 3D plots as well as image displays. In this quick tutorial, we will cover the basics of using PyQtGraph to create a simple 2D plot.
Step 1: Installation
First, you will need to install PyQtGraph. You can do this using pip:
pip install pyqtgraph
Step 2: Create a Simple Plot
Once you have PyQtGraph installed, you can create a simple 2D plot by following the code below:
import pyqtgraph as pg
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
pg.plot(x, y, title='Simple 2D Plot')
Step 3: Display the Plot
To display the plot, you can simply call the show()
method:
pg.show()
Conclusion
That’s all there is to creating a simple 2D plot using PyQtGraph! Stay tuned for more tutorials on using PyQtGraph for data visualization.
I have data coming from a USB-Serial Port.. and would like to plot the data real-time as it comes in.
Unfortunately, my dummy PyQt multiprocessing application starts off fast, but gets progressively slower with each new data point. I separated one process for the serial port, and another for the PyQtGraph/GUI part, and a pipe in-between.
Not sure where the bottleneck is, perhaps the appending to the numpy array or a bottleneck in the pipe.. either way, not sure if there's a better approach / library that would work better in this case?
Awesome tutorial