pyqtgraph icon indicating copy to clipboard operation
pyqtgraph copied to clipboard

clipToView should be also for y range

Open flipflop133 opened this issue 5 months ago • 0 comments

Short description

clipToView doesn't draw points only for points not visible on x range but it should do it also for y range.

Code that do it for both ranges ( replace this code )

if self.opts['clipToView']:
            if view is None or view.autoRangeEnabled()[0]:
                pass  # no ViewBox to clip to, or view will autoscale to data range.
            else:
                # clip-to-view always presumes that x and y values are in increasing order
                if view_range is not None and len(x) > 1 and len(y) > 1:
                    # Find the x-range of the view
                    left = view_range.left()
                    right = view_range.right()
                    bottom = view_range.bottom()
                    top = view_range.top()
                   
                    # Determine the masks
                    mask_x = (x >= left) & (x <= right) 
                    mask_y = (y >= top) & (y <= bottom)

                    # Combine the masks for both x and y axes
                    mask = mask_x & mask_y

                    # Apply the mask to x and y
                    x = x[mask]
                    y = y[mask]

NOTE: I didn't created a pr because I'm not sure about how we should adjust the range using ds (downsampling) like is done in original block code. This would greatly improve performances when having multiple plots with a lot of data and locking x axis (for example when we have data based on a depth or time index).

flipflop133 avatar Sep 11 '24 14:09 flipflop133