Repository: microsoft/Qcodes

Issue:
qcodes.plots.pyqtgraph.QtPlot.update_plot() not compatible with pyqtgraph==0.13.1 
###
I'm one of the developers of quantify and our package heavily depends on qcodes. The latest pyqtgraph release (0.13.1) brought a few changes that we needed to address and unfortunately one issue actually stems from within qcodes. 

I don't have nice minimal working example, but I think the issue should be clear. We have a `PlotMonitor` class that launches multiple instances of `QtPlot` which right after running `update_plot` raises an `AttributeError` with the following traceback

```
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-core/envs/382/lib/python3.8/site-packages/quantify_core/visualization/pyqt_plotmon_remote.py", line 158, in _exec_queue
    getattr(self, attr_name)(*args)
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-core/envs/382/lib/python3.8/site-packages/quantify_core/visualization/pyqt_plotmon_remote.py", line 664, in update
    self.secondary_QtPlot.update_plot()
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-core/envs/382/lib/python3.8/site-packages/qcodes/plots/pyqtgraph.py", line 468, in update_plot
    self._update_image(plot_object, config)
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-core/envs/382/lib/python3.8/site-packages/qcodes/plots/pyqtgraph.py", line 307, in _update_image
    img.translate(scales['x'].translate, scales['y'].translate)
AttributeError: 'ImageItem' object has no attribute 'translate'
```
(`secondary_QtPlot` is assigned to an instance of QtPlot)

Looking at the documentation of pyqtgraph, the "new" way of applying transforms is via `QtGui.QTransform()`. The example they give is

``` python
tr = QtGui.QTransform()  # prepare ImageItem transformation:
tr.scale(6.0, 3.0)       # scale horizontal and vertical axes
tr.translate(-1.5, -1.5) # move 3x3 image to locate center at axis origin

img = pg.ImageItem( image=np.eye(3), levels=(0,1) ) # create example image
img.setTransform(tr) # assign transform
```

I think the issue is resolved when we replace all lines containing `img.translate` and `img.scale` with `img.setTransform`. 

The issue arose with `qcodes==0.33.0` and `pyqtgraph==0.13.1`. 



Discussion:
@rsokolewicz thanks for reaching out. Honestly that code sees very little use for us internally. I am happy to merge a pr that fixes this but it might take a bit of time before we get to it otherwise

Resolving patch:
diff --git a/qcodes/plots/pyqtgraph.py b/qcodes/plots/pyqtgraph.py
--- a/qcodes/plots/pyqtgraph.py
+++ b/qcodes/plots/pyqtgraph.py
@@ -317,8 +317,11 @@ def _update_image(self, plot_object, config):
 
         if scales_changed:
             img.resetTransform()
-            img.translate(scales['x'].translate, scales['y'].translate)
-            img.scale(scales['x'].scale, scales['y'].scale)
+            tr = QtGui.QTransform.fromTranslate(
+                scales["x"].translate, scales["y"].translate
+            )
+            tr_scale = QtGui.QTransform.fromScale(scales["x"].scale, scales["y"].scale)
+            img.setTransform(tr_scale * tr)
 
     def _update_cmap(self, plot_object):
         gradient = plot_object['hist'].gradient


Test patch: