0

I have an app where my users are requesting that I smooth the curves connecting points in a line or scatter plot. This is usually an option in spreadsheet charts.

Here's a crude example of plotting a sine function with points every 45 degrees.

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg

app = QtGui.QApplication([])

win = pg.GraphicsWindow(title="Basic plotting examples")
win.resize(1000,600)
win.setWindowTitle('pyqtgraph example: Plotting')

# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)

angles = np.radians(np.arange(0,360+45, 45))

p1 = win.addPlot(title="Rough sine wave", y=np.sin(angles), symbolBrush=(255,0,0), symbolPen='w')

## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()

enter image description here

I'd like it if I could get a smooth curve through the points, like in this plot from LibreOffice:

enter image description here

Is there any way to do this in pyqtgraph? In this example, I can get a smoother curve by just graphing every 1 degree instead of every 45 degrees. However in my real world app, I am downloading data from a GPIB instrument. And it's slow. So if I was to get more points from my instrument, my app would get even laggier than it is now.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
bfris
  • 5,272
  • 1
  • 20
  • 37
  • 1
    think you gotta go for the gllineplot – Havihavi Dec 18 '20 at 05:50
  • @Havihavi, I see your point. In the examples, under 3D Graphics there is a Line Plot example and they show how to use GlLinePlotItem. That gives nice, smoothed traces. It looks like a lot of extra overhead to make it work for 2D. – bfris Dec 18 '20 at 17:31

0 Answers0