I want to build a hexbin plot in matplotlib where the width of the line for each hexagon is a function of the number of observations that fall in that hexagon. I think this will be useful for adding an additional level of inference to a hexbin plot.
So far, I have the following code:
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(0,1,1000)
y = np.random.uniform(0,1,1000)
z = np.random.uniform(0,1,1000)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.hexbin(x , y, C = z, gridsize=50, edgecolors='white')
This creates a hexbin plot where the color of the bin is a function of the average z value for x,y pairs in the bin.
Is there a way to set the line widths of the hexes to be a function the the number of observations in each in?
Ultimately I want thicker lines for less populated hexes. This should result in smaller visible hexes.