Probably the easiest option is to use pcolormesh instead of the imshow graph. pcolormesh shows the edges of the grid, so you can simply transform the original grid using the functional relationship between pixels and wavelength to determine the edges of each pixel by wavelength.
import numpy as np import matplotlib.pyplot as plt image = np.sort(np.random.randint(0,256,size=(400,600)),axis=0) f = lambda i: i**3*-3.119E-6+2.926E-3*i**2+0.173*i+269.593 xi = np.arange(0,image.shape[1]+1)-0.5 yi = np.arange(0,image.shape[0]+1)-0.5 Xi, Yi = np.meshgrid(xi, yi) Xw = f(Xi) fig, (ax) = plt.subplots(figsize=(8,4)) ax.pcolormesh(Xw, Yi, image) ax.set_xlabel("wavelength [nm]") plt.show()

If the image has 3 color channels, you need to use the color argument for pcolormesh to specify the color of each pixel, as shown in this question: Overlapping irregularly spaced RGB image in Python
import numpy as np import matplotlib.pyplot as plt r = np.sort(np.random.randint(0,256,size=(200,600)),axis=1) g = np.sort(np.random.randint(0,256,size=(200,600)),axis=0) b = np.sort(np.random.randint(0,256,size=(200,600)),axis=1) image = np.dstack([r, g, b]) color = image.reshape((image.shape[0]*image.shape[1],image.shape[2])) if color.max() > 1.: color = color/255. f = lambda i: i**3*-3.119E-6+2.926E-3*i**2+0.173*i+269.593 xi = np.arange(0,image.shape[1]+1)-0.5 yi = np.arange(0,image.shape[0]+1)-0.5 Xi, Yi = np.meshgrid(xi, yi) Xw = f(Xi) fig, (ax) = plt.subplots(figsize=(8,4)) pc = ax.pcolormesh(Xw, Yi, Xw, color=color ) pc.set_array(None) ax.set_xlabel("wavelength [nm]") plt.show()