Reputation: 5618
I am plotting a numpy
matrix with imshow
and nearest neighbor interpolation in blue scale.
How can i color specific pixels in the plot so that they would be, say red?
pyplot.imshow(matrix, interpolation='nearest',cmap = cm.Blues)
pyplot.show()
Upvotes: 1
Views: 6775
Reputation: 16249
You can't directly color pixels red with a colormap that doesn't have red in it. You could pick a red-blue colormap and norm your matrix data into the blue part, but you can also just plot over an imshow image:
from matplotlib import pyplot
from numpy.random import random
matrix = random((12,12))
from matplotlib import cm
pyplot.imshow(matrix, interpolation='nearest', cmap=cm.Blues)
pyplot.scatter([6,8], [10,7], color='red', s=40)
pyplot.show()
Upvotes: 5