Just for fun I'm trying to code a mouse tracking script, I have the basic part working, but I'm having absolutely no luck with heatmaps.
My initial code was to save an image via PIL (just to check it was working), which was fine, but obviously it was only single dots. I then tried to implement my own heat map, but found that it'd take over half a year of processing for something really basic, so that wasn't going to work either.
I've been trying different examples of matplotlib, but I've just realised "heat map" means something different in this case.
It's not not working, but it's also definitely not the result I was hoping to see. I'm wondering if anyone knows how I'd actually go about getting the other type of heatmap, where you get the blobs of heat? I've been googling a bunch of terms but it seems to lead back to the same 3 or so SO questions.
The data is stored in a dictionary of {(x, y): frequency}
, so to get the result above I used this code (matplotlib part got from Plotting a 2D heatmap with Matplotlib):
import matplotlib.pyplot as plt
resolution = (1920, 1080)
total = []
for y in range(resolution[1]):
row = []
for x in range(resolution[0]):
try:
row.append(data[(x, y)])
except KeyError:
row.append(0)
total.append(row)
plt.imshow(total, cmap='hot', interpolation='nearest')
plt.show()
The speed of that doesn't matter so much as it'll be done separately to the tracking, I'd just like something that'd initially work.
Edit: Just to clear it up a little (apologies if it wasn't clear), something like this is what I'd like: