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
Il giorno giovedì 20 gennaio 2022 alle 14:53:27 UTC+1 [email protected] ha
scritto:
> Hi!
>
> I am having the same problem, everything about pyqtgraph is so fast. But I
> have the same problem. I have to plot several vertical lines, at different
> heights, using spans depending on the number of different levels I need to
> set.
>
> It looks something like this
>
> for key, values in prf.reflections.items():
> span = ((float(key) - 1)/prf.nphase, float(key)/prf.nphase)
>
> for val in values:
> line = pg.InfiniteLine(pos=val, angle=90, pen=self.pen8, span=span)
> self.ui_mainwindow.peaks_graph.addItem(line)
>
> This is painfully slow so I am wondering if there is a better way.
>
>
>>
--
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/b8d18bb1-8a02-4bf4-86be-5a3684bd880cn%40googlegroups.com.