If by 'color value' you mean the value of the array at a clicked point on a graph, then this is useful.
from matplotlib import pyplot as plt
import numpy as np
class collect_points():
omega = []
def __init__(self,array):
self.array = array
def onclick(self,event):
self.omega.append((int(round(event.ydata)), int(round(event.xdata))))
def indices(self):
plot = plt.imshow(self.array, cmap = plt.cm.hot, interpolation = 'nearest', origin= 'upper')
fig = plt.gcf()
ax = plt.gca()
zeta = fig.canvas.mpl_connect('button_press_event', self.onclick)
plt.colorbar()
plt.show()
return self.omega
Usage would be something like:
from collect_points import collect_points
import numpy as np
array = np.random.rand(10,10)*255
indices = collect_points(array).indices()
A plotting window should appear, you click on points, and returned are the indices of the numpy array.