Using matplotib in python it is possible to make a simple histogram by providing the list of items to be plotted together with a list of weights, such that the contribution of each item to the bin to which it belongs is adjusted according to its weight, e.g.
import matplotlib.pyplot as plt
...
plt.hist(items, weights = weightsOfItems)
I am trying to plot a hexagonal bin histogram of two values against each other, which can be done using
plt.hexbin(xValues, yValues)
As before, I would like the contributions of each pair to the bin to which it belongs to be adjusted according to a list of weights. From the hexbin
documentation it seems like I should be able to do this by giving an input for the parameter C, i.e.
plt.hexbin(xValues, yValues, C = weightsOfValues)
Doing this, however, yields completely incorrect plots. For the time being I have resorted to first sampling my xValues and yValues according to the weights to give xSamples and ySamples. This process, however, is very time consuming and also means that I do not use all of the data available since I get rid of xValues and yValues not included in the samples.
So, does anyone know of a way to produce a hexagonal bin histogram where the contribution of values to their respective bins is adjusted for according to given weights?