Reputation: 33
I already normalized my data to a colormap, I just dont know how to plot it. Here is the type of figure I want to create:
I want to create something similar using the cmap 'bwr' where a value of '1' would be solid red and '0' would be solid blue. I used this to normalize my data and map it to the colors:
norm = Normalize(vmin = min(data), vmax = max(data), clip = True)
mapper = cm.ScalarMappable(norm = norm, cmap = plt.get_cmap('bwr'))
so the data[0]
would be the far left of the figure and the last value in the list would be the far right.
Upvotes: 0
Views: 669
Reputation: 339170
If I understand correctly you want to create an image. This can be done via imshow
.
import numpy as np
import matplotlib.pyplot as plt
# some data
data = np.atleast_2d(np.sin(np.sqrt(np.linspace(1,250,250)))*34)
# plot image
plt.imshow(data, aspect="auto", cmap="bwr")
plt.show()
Upvotes: 2