I am working in a heat map for some eye tracking data. I figured out how to do the heat map and it is very compelling. This is the code:
ggplot(eyematrixCorrectMatchControl, aes(x = CURRENT_FIX_X, y =CURRENT_FIX_Y)) +
annotation_raster(image, -Inf, Inf, -Inf, Inf, interpolate = TRUE) +
stat_density2d(data= eyematrixCorrectMatchControl, aes(x = CURRENT_FIX_X, y =CURRENT_FIX_Y, fill = ..level.., alpha = ..level..), size= 10, bins= 50, geom='polygon') +
theme_bw() +scale_fill_gradient(low = "blue", high = "red") +
scale_alpha_continuous(range=c(0.01,0.25) , guide = FALSE) +
coord_cartesian(xlim= c(0,1024), ylim= c(0,768))+
scale_y_reverse() +
theme(axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank())
With this code, I obtain this image:
However, I don't understand some things. I thought that this code would give me a graph the number of fixations in a specific area (the more fixation the redder the area is). However, looking at the legend I am not sure what this graph shows. How can I obtain a graph showing the number of fixations? I would also like that the legend reflects the number of fixations, so the redder the more fixations. Any idea??
I edit to add some extra information that might be useful. In my original dataframe I also have a variable called fixation_index. I think that I have to include this variable somewhere, but not really sure.
Thanks!