Question

I am trying to plot a heatmap using the maxplotlib hexbin function, but I somehow get some regularly placed white spots on the plot, as shown below: whie spots on the hexbin plot

I essentially have a function f:R^2- loading=R"> that evaluates to a real, and then I follow the typical steps for hexbin (I am always sure that the problem is not with the f function).

My code is shown below. Any insight would be appreciated..

# Values for the axes
x = y = np.linspace(-400,1000,100) 
X, Y = np.meshgrid(x,y)
z_s = np.zeros((len(x),len(y)))
z_j = np.zeros((len(x),len(y)))

# Generate the values using the `f` function
for i_ax, ax in enumerate(x):
    for i_ay, ay in enumerate(y):
        z_s[i_ax, i_ay] = f(ax, ay)
# Plot
Xr = X.ravel()
Yr = Y.ravel()
Zr_s = z_s.ravel()

fig = plt.figure()
plt.hexbin(Xr, Yr, C = Zr_s)

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top