My hexbin plot won’t center at xC=0, yC=0 even though both axes are symmetric.
I’ve marked the center with green lines. As you can see, it does not match. The center of the last bins on the left are exactly where they are supposed to be, at -1.016*0.5. The center of the last bins on the right aren’t. Same problem for the y-axis. The bottom is correct and the top isn’t.
These are my axes:
xC = np.linspace(-1.016*0.5, 1.016*0.5, int(2e3))
yC = np.linspace(-0.756*0.5, (0.756*0.5), int(2e3))
I then turn them into meshgrids:
XX, YY = np.meshgrid(xC[::10], yC[::10])
The plot contains a function I(XX,YY,z) which I don’t think I should explain here because it’s not relevant to the problem.
fig = plt.figure(figsize = (12,6))
colormapI_A_hex = plt.hexbin(XX.flatten(),
YY.flatten(),
(I(XX,YY,z).flatten(),
gridsize=(8,4),
cmap='gnuplot')
colormapI_A_cbar_hex = fig.colorbar(colormapI_A_hex, label='Intensity $I_A$ [W/m$^2$]')
plt.show()
Why does this happen and how do I fix it?