I want to plot a graph with multiple curves(although in this particular example all plots are linear), and then plot the sum of the graphs as an additional plot.
I was wondering whether there was a built in way to do it, rather than calculating for each new (x,y) point the coordinates of all other curves at that point and summing them up.
Here's a quick example(it runs as a standalone script):
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
app = QtGui.QApplication([])
win = pg.GraphicsWindow(title="For Test")
plot = win.addPlot(title='Test')
#First plot:
x = [1,3,5,7]
y = [1,2,1,2]
curve1 = plot.plot(x=x, y=y, pen='r')
#Second plot
x = [2,4,6,8]
y = [0.5,4,2,2]
curve2 = plot.plot(x=x, y=y, pen='g')
if __name__ == '__main__':
app.exec_()
Expected result is something like:
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [1, ~2, ~4, ~5.5, ~8, ~3.5, 4, 2]
This problem gets a bit harder if there are actual curves. So is there a built in way to do it?