I needed to plot hundreds of vertical lines corresponding to some
transitions.
At the beginning I tried to use InfiniteLine but it was too slow. At the
end I arrived at this solution that seems to work.
class plotVerticalLines(pg.PlotDataItem):
def dataBounds(self, ax, frac=1.0, orthoRange=None):
return [None, None]
def setVerticalLines(self, x):
x = np.vstack((x,x)).T.astype(float)
y = np.zeros_like(x)
vb = self.getViewBox()
xr, yr = vb.viewRange()
y[:,0] = yr[0]
y[:,1] = yr[1]
self.setData(x.ravel(), y.ravel(), connect='pairs')
vb.sigYRangeChanged.connect(self._y_range_changed)
def _y_range_changed(self, viewbox):
xr, yr = viewbox.viewRange()
# get the original not transfomed clipped etc.
x = self.xData
y = self.yData
y[0::2] = yr[0]
y[1::2] = yr[1]
self.setData(x, y, connect='pairs')
Have you comment?
or way to improve it?
I really thanks the author of this really great library. I was able to get
what I wanted with just few lines of code.
Cheers
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/70ed8801-1181-4b11-a073-d511daffd65a%40googlegroups.com.