最も簡単な解決策は、最初に入力データの RGBA 色を計算し、それを操作して特別な色 (緑) とは異なる値を設定し、次に単純なimshow()
変更された RGBA 配列でプロットすることです。これを行う方法は次のとおりです。
>>> rgba_values = cm.gray(y) # All RGBA values for your input value, with levels of gray
>>> rgba_values[x != y] = [0, 1, 0, 1] # Set the points where x and y differ to green (RBG = 0, 1, 0)
>>> imshow(rgba_values, interpolation='nearest')
配列間で異なり、現在は緑色になっているデータx
ポイントy
:

以前に表示された画像に緑色の点を重ねる場合は、同様のことを行い、元の画像を変更したくない場所でアルファ チャネルを 0 に設定できます。
>>> y_gray = cm.gray(y) # RGBA image with gray levels
>>> imshow(y_gray, interpolation='nearest') # Image of one of the arrays
>>> diff_points = numpy.empty_like(y_gray) # Preparation of an overlay with marked points only
>>> diff_points[x == y, 3] = 0 # Common points not overwritten: alpha layer set to 0
>>> diff_points[x != y] = [0, 1, 0, 1] # Green for points that differ
>>> imshow(diff_points, interpolation='nearest')