I have a set of X,Y data points (about 10k) that are easy to plot as a scatter plot but that I would like to represent as a heatmap.
I looked through the examples in MatPlotLib and they all seem to already start with heatmap cell values to generate the image.
Is there a method that converts a bunch of x,y, all different, to a heatmap (where zones with higher frequency of x,y would be "warmer")?
If you don't want hexagons, you can use numpy's
import numpy as np import numpy.random import matplotlib.pyplot as plt # Generate some test data x = np.random.randn(8873) y = np.random.randn(8873) heatmap, xedges, yedges = np.histogram2d(x, y, bins=50) extent = [xedges, xedges[-1], yedges, yedges[-1]] plt.clf() plt.imshow(heatmap.T, extent=extent, origin='lower') plt.show()
This makes a 50x50 heatmap. If you want, say, 512x384, you can put
bins=(512, 384) in the call to