I'm tracking a subject's gaze over a specified area of a computer screen. I'm constructing gaze heatmaps using pyplot's hist2d
function.
Here's a simple example:
figure()
hist2d(xval, yval, bins=1000)
xlim([-6, 6])
ylim([-4.5, 4.5])
As you can see, there is a significant area outside of the range of my data. However, I would like to set this area to the blue indicative of a zero-value.
My first attempt using imshow
can be seen here:
figure()
imshow(np.array([[0] * 8] * 12), extent=[-6, 6, -4.5, 4.5])
hist2d(xval, yval, bins=1000)
xlim([-6, 6])
ylim([-4.5, 4.5])
This sort of works, but leaves an ugly vertical line at the boundary of my data's range.
My questions are as follows:
imshow
callOkay, I've figured it out. It's actually rather simple: one just needs to manipulate the range
kwarg.
figure()
#imshow(np.array([[0] * 8] * 12), extent=[-6, 6, -4.5, 4.5])
hist2d(xval, yval, bins=1000, range=np.array([(-6, 6), (-4.5, 4.5)]))
xlim([-6, 6])
ylim([-4.5, 4.5])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With