Is there an inverse colormap function? It looks like not, but I figured I’d ask.
For example, if I make a colormap, I can send it a value and it’ll return the RGBA number corresponding to that value. Is there a way I can send it an RGBA number and have it return the value that maps to that number?
Here’s some example code; the commented line is what I’m interested in:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
z = np.reshape(np.arange(25),(5,5))
myCMap = cm.get_cmap('viridis',25)
figH,axH = plt.subplots(1,1)
axH.pcolormesh(z,cmap=myCMap)
z22_c = myCMap(z[2,2])
# z22_val = myCMap.inverse(RGBA=z22_c)
# Ideally z22_val is the value at z[0,0], i.e. the value that caused myCMap to
# give the RGBA color z22_c.
From looking/digging around, it looks like that’s not a thing, but figured I’d ask.