The span is the fraction of the View (that in my previous case was all the View) that the line span. Even if you are zooming. But from what I see in your case it seems that it has instead a physical meaning not related to your view (I may be wrong of course).
In may case I reset the span whenever the view change (due for example to a zoom or a pan action by the user). It will be easy to add the span in the object itself then use the memorized span to calculate the correct y position in the _y_range_changed method.
Add an arguments to the setVerticalLines:
def setVerticalLines(self, x, spans):
self.spans = spans
In _range_changesd retrieve the spans (Assuming they are (n,2) matrices) and normalize them to the viewBox and set the y array.
Add also a check to test if the spans are defined like:
if not hasattr(self,'spans'):
return
y[0::2] = self.spans[:,0] * (yr[1] - yr[0]) + yr[0]
y[1::2] = self.spans[:,1] * (yr[1] - yr[0]) + yr[0]
If instead your y positions are fixed it will be even easier as you don't need a method that change them when the viewbox changes.
keys = prf.reflections.keys()
values = prf.reflections.values()
x = np.vstack((values,values)).T.astype(float)
y = np.zeros_like(x)
y[:,0] = (float(keys) - 1)/prf.nphase
y[:,1] = float(key)/prf.nphase
.....setData(x.ravel(), y.ravel(), connect='pairs')
or plot or which ever you prefer