Can a pyqtgraph.GraphicsObject be in two plots

Viewed 97

I have two plots for left and right sensors. The plots have both their axes locked and will have certain labes and lines which should be rendered identically on both plots.

If I use addItem to add my items to 2 plots, it appears the second plot always gets the item.

import pyqtgraph as pg

from PyQt5 import QtCore, QtWidgets

app = QtWidgets.QApplication([])

view = pg.GraphicsView()
l = pg.GraphicsLayout()
view.setCentralItem(l)
view.show()
view.resize(800,600)

p0 = l.addPlot(0, 0)
p1 = l.addPlot(1, 0)

p1.setXLink(p0)
p1.setYLink(p0)

line = pg.InfiniteLine()

p0.addItem(line)
p1.addItem(line)

app.exec_()

Is there anyway to have a single item on both plots? or a better way to skin this cat?

0 Answers
Related