I guess to answer my own question, yes, using QtGui.QTransform seems to be
the way now:
old way:
self.Img = pg.ImageItem()
self.Img.scale((data_storage.x[-1] - data_storage.x[0]) /
len(data_storage.x), 1)
self.plot.clear()
self.plot.addItem(self.waterfallImg)
which now fails with
TypeError: ImageItem.scale() takes no arguments (2 given)
new way:
self.Img = pg.ImageItem()
tr = QtGui.QTransform()
tr.scale((data_storage.x[-1] - data_storage.x[0]) /
len(data_storage.x), 1)
self.waterfallImg.setTransform(tr)
self.plot.clear()
self.plot.addItem(self.waterfallImg)
Works now the way it used to
I don't see this documented anywhere as an API change
On Monday, November 14, 2022 at 11:45:37 PM UTC-8 Andrew Hakman wrote:
> I recently upgraded my machine and am now using QT 6.3.1 and pyqtgraph
> 0.13.1-3
>
> There seems to be an API change with ImageItem.scale() that breaks
> existing code that was working perfectly before the upgrade.
>
> As best I can tell, scale() is inherited from QGraphicsItem, and at some
> point in the past, it used to take 2 arguments x_scale,y_scale, but now
> takes none.
>
> There are a few examples around of setting the scale of the image based on
> the number of points in my data, like this one from here:
> https://www.mail-archive.com/[email protected]/msg00740.html
> <https://www.mail-archive.com/[email protected]/msg00740.html>
>
> self.image = pg.ImageItem(np.zeros((1, 1)))
> self.plot.addItem(self.image)
> self.image.setImage(image)
> # x-axis coordinate values are wavelengths (eg, 450--750)
> # y-axis coordinates are simply the camera pixel numbers (0--199)
> self.xlabels = np.arange(450, 750)
> # Translate and scale the ImageItem to match the x-axis labels
> self.image.translate(self.xlabels[0], 0)
> self.image.scale((self.xlabels[-1] - self.xlabels[0])/len(self.xlabels), 1)
>
> You can find various examples of ImageItem.scale(x_scale, y_scale) when
> googling a bit.
>
> But now after the update to either QT or pyqtgraph (or both), that last
> line throws the error
>
> TypeError: ImageItem.scale() takes no arguments (2 given)
>
> So what's the new way to do this now? Is it using QtGui.QTransform, and
> then assigning the transform to the ImageItem?
>
> I can't even find an older version of the QT API or the PyQTGraph API that
> shows a scale function that takes any arguments (so that's why I'm unsure
> which class the scale function used to even come from).
>
--
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/904669d3-4e6f-4ed0-94f3-84ddb5fb97b4n%40googlegroups.com.