I start from two linspaces and I meshgrid them. Then I calculate a function's values on grid. My function is called cpt_hcpv(). Then I would like to heatmap my data, with each point on the grid with its corresponding function value.
Code looks like
poro = np.linspace(min(poro), max(poro))
sw = np.linspace(min(sw), max(sw))
g = np.meshgrid(poro, sw)
points = zip(*(x.flat for x in g))
hcpv = []
for p in points:
hcpv = hcpv + [cpt_hcpv(p[0], p[1], poro, sw)]
with
def cpt_hcpv(pCut, sCut, poro, sw):
#find points belonging to calculation
truncated = [(p, s) for p, s in zip(poro, sw) if p > pCut and s < sCut ]
hcv = 0
for k in truncated:
hcv += p*(1-s)*0.5
return hcv
Why I am not computing cpt_hcpv() directly on grid: because I have to deal with condition in comprehension truncated = [(p, s) for p, s in zip(poro, sw) if p > pCut and s < sCut ] so that I must iterate on the point in grid. I don't know how to iterate on a meshgrid.
So, I would like to heatmap from the 3d coordinates: in points I have x and y for the points and in hcpv I have the z parameters for each point, in same order.
From the examples I have found, there are pylab and matplotlib solutions to plot heatmap from meshgrid + values computed on the grid, with a method taking meshgrid as an argument.
Is there a way to plot heatmap from 3d coordinates ?
pcolorandpcolormesh? - tacaswell