I need to visualize some data. It's basic 2D grid, where each cell have float value. I know how to e.g. assign color to value and paint grid in OpenCV. But the point here is that there are so many values so it's nearly impossible to do that. I am looking for some method, where I could use gradient. For example value -5.0 will be represented by blue, 0 - black, and +5.0 as red. Is there any way to do that in Python?
Here is sample data I am talking about
A B C D
A -1.045 2.0 3.5 -4.890
B -5.678 3.2 2.89 5.78
解决方案
Matplotlib has the imshow method for plotting arrays:
from matplotlib import mpl,pyplot
import numpy as np
# make values from -5 to 5, for this example
zvals = np.random.rand(100,100)*10-5
# make a color map of fixed colors
cmap = mpl.colors.ListedColormap(['blue',