I want to create a heatmap of a dataset from excel. For example the following dataset: https://i.stack.imgur.com/fXZS5.png. So the x- and y-values are the x- and y-coordinates. If the z-value is high I want that coordinate to be darker (for example red) and if z-value is low it should be lighter (for example blue).
I thought this code would work, but I got some errors. How can I solve this? The error I got: IndexError: list index out of range. It points out it has to do something with the line of "PLT.hexbin(x, y, C=z, gridsize=gridsize, cmap=CM.jet, bins=50)"
from matplotlib import pyplot as PLT
from matplotlib import cm as CM
import numpy as NP
import xlrd
file_location = "C:/Users/Niels/Desktop/Test.xlsx"
workbook = xlrd.open_workbook(file_location)
sheet1 = workbook.sheet_by_index(0)
colomnValues = sheet1.col_values(2)
x = NP.linspace(0,10,100)
y = NP.linspace(0,1,100)
X, Y = NP.meshgrid(x, y)
x = X.ravel()
y = Y.ravel()
z = colomnValues
gridsize=50
PLT.subplot(111)
PLT.hexbin(x, y, C=z, gridsize=gridsize, cmap=CM.jet, bins=50)
PLT.axis([x.min(), x.max(), y.min(), y.max()])
cb = PLT.colorbar()
cb.set_label('mean value')
PLT.show()