Hi Alan, The new, accepted way to do this is by applying a QTransform to the ImageItem. Something like this:
# Axis labels or limits for the x and y pixels # If pixel values, they need to be uniform intervals x = np.array([-1024, 1024]) y = np.array([-1024, 1024]) # Scale in units per pixel x_scale = (x[-1] - x[0])/(x.shape[0]-1) if x.shape[0] > 1 else 1.0 y_scale = (y[-1] - y[0])/(y.shape[0]-1) if y.shape[0] > 1 else 1.0 # Create QTransform and apply to ImageItem # Adjust so values are centred on pixels tr = QtGui.QTransform() tr.translate(x[0] - x_scale/2, y[0] - y_scale/2) tr.scale(x_scale, y_scale) image.setTransform(tr) It's just calculating the translation and pixel scale required to map the pixel coordinates to the desired axis coordinates. Patrick On Wednesday, 13 July 2022 at 7:56:44 am UTC+9:30 Alan Wang wrote: > Hi all, > I'm making a graph that displays an image with an ImageItem and > GraphicsLayoutWidget, but I'd like to label the image with axes on a > different system of coordinates. When I create a graph, the axes go from 0 > to 4096 (the size of the image), but I'd like the axes to be labeled from > -1024 to 1024, essentially remapping the coordinates to a different scale. > Is there a way to do this? > > Thank you > -- 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/85ab2e7c-5418-4946-9110-800983b05387n%40googlegroups.com.
