Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plot.py #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sdn-ninja
Copy link

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)

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.

None yet

2 participants