If by "color value" you understand the value of the array at the click point on the chart, 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 will be something like this:
from collect_points import collect_points import numpy as np array = np.random.rand(10,10)*255 indices = collect_points(array).indices()
A build window should appear, you click on the points and return the indices of the numpy array.
William Rudisill
source share