Skip to content

Update plot.py#111

Open
jomosh wants to merge 1 commit intoxmikos:masterfrom
jomosh:qspectrumanalyzer_fix_imageItem.scale
Open

Update plot.py#111
jomosh wants to merge 1 commit intoxmikos:masterfrom
jomosh:qspectrumanalyzer_fix_imageItem.scale

Conversation

@jomosh
Copy link

@jomosh jomosh commented Feb 1, 2024

The new ImageItem.scale() (from pyqtgraph) no longer accepts any arguments

The new ImageItem.scale() (from pyqtgraph) no longer accepts any arguments
@Eths33
Copy link

Eths33 commented May 8, 2024

I also saw the same error probably. [ I installed via pip3 ]

Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\qspectrumanalyzer\plot.py", line 298, in update_plot
    self.waterfallImg.scale(x_scale)
TypeError: scale(self): too many arguments

I updated the function like this with additional checks. I have not tested much though.

def update_plot(self, data_storage):
        """Update waterfall plot"""
        self.counter += 1

        # Calculate scale if there is enough data, else default to 1
        if len(data_storage.x) > 1:
            uniform_scale = (data_storage.x[-1] - data_storage.x[0]) / len(data_storage.x)
        else:
            uniform_scale = 1  # Default scale if not enough data

        # Create waterfall image on first run
        if self.counter == 1:
            self.waterfallImg = pg.ImageItem()
            self.waterfallImg.setScale(uniform_scale)  # Using setScale for uniform scaling
            self.plot.clear()
            self.plot.addItem(self.waterfallImg)

        # Ensure there is new data to update
        if data_storage.history.buffer.shape[0] >= self.counter:
            # Roll down one and replace leading edge with new data
            self.waterfallImg.setImage(data_storage.history.buffer[-self.counter:].T,
                                    autoLevels=False, autoRange=False)

            # Move waterfall image to always start at 0
            self.waterfallImg.setPos(
                data_storage.x[0] if len(data_storage.x) > 0 else 0,
                -self.counter if self.counter < self.history_size else -self.history_size
            )

            # Link histogram widget to waterfall image on first run
            if self.counter == 1 and self.histogram_layout:
                self.histogram.setImageItem(self.waterfallImg)

@vixadd
Copy link

vixadd commented Sep 24, 2024

I've provided a solution for this bug in this PR as well. #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants