Hi,
This is some simplified parts from my code that I think does what you describe: # Set up the plot and add the ImageItem self.plot = self.plot_graphicsLayoutWidget.addPlot() self.plot.showGrid(x=True, y=True) self.plot.setLabels(bottom="Wavelength (nm)") self.image = pg.ImageItem(np.zeros((1, 1))) self.plot.addItem(self.image) #... # Acquire image from somewhere and set the ImageItem to use it 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) <https://lh3.googleusercontent.com/-FhX91HhYu1M/Wup9s44M_mI/AAAAAAAAD80/70qwjTVXiq0HhSeCeIqe0sBn2IJKtCF3QCLcBGAs/s1600/Capture.PNG> Patrick On Thursday, 3 May 2018 06:23:37 UTC+9:30, S Martin wrote: > > Hello, > > I am trying to use ImageView to display an image but with axis included > and specified y range. Basically I'm doing something like this: > > plt = pg.PlotItem(labels={'bottom':('time',''),'left':('frequency','')}) > imv = pg.ImageView(view=plt) > x0, x1 = (0, 500) > y0, y1 = (0, 16) > xscale = (x1-x0)/img.shape[0] > yscale = (y1-y0)/img.shape[1] > imv.setImage(img, pos=[x0,y0], scale=[xscale, yscale]) > plt.setAspectLocked(False) > > Now the xaxis runs 0 to 500 left to right, but the yaxis runs 0 to 16 top > to bottom. However, I want the yaxis to start at the bottom at 0 and run > to 16 at the top (a usual increasing y axis). I am not sure how to set the > axis range within ImageView. > > Thanks, > Steve > > -- 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/251a6d1c-32f1-49e8-af76-92ae741ff12c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
