I've got the following code:
x = range(1, 100) # pixel x coordinates
y = range(21, 120) # pixel y coordinates
z = [-2, 5, 1, ..., 1] # should be mapped to colors
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.colors import Normalize
cmap = cm.autumn
norm = Normalize(vmin=min(z), vmax=max(z))
colormap = cmap(norm(5))
plt.plot(x, y, cm=colormap)
And now I want to plot these points [x, y]
such that:
- Each point should be a pixel (since
len(x)
may be about35'000
), not just a marker (I'm afraid they'll overlap otherways). - Using this question, I'd like to take a colormap and map
min(z)
to let's say white color andmax(z)
to a black color (and display a legend).
How can I do it using matplotlib?