# Solution 4
# S with boxes ------------------------------------------------------------
p <-
ggplot(d, aes(x = CURRENT_FIX_X, y =CURRENT_FIX_Y)) +
annotation_custom(grob = image_1, # Image
xmin= 0, # Coordinates to represent the image
xmax= 1000,
ymin= 0,
ymax= 800
) +
coord_fixed(xlim = c(0, 1000), ylim = c(0, 700)) +
geom_point(data= d, aes(x = CURRENT_FIX_X, y =CURRENT_FIX_Y), # coordinates
color="black", # Color point
# position=position_jitter(w=0.01,h=0.01), # Point plot desviation
alpha=0.5) + # Point transaparecen
stat_bin2d(bins = 10, colour = "gray", alpha = 0.5) +
theme_bw() + # Kind of theme. I strongly recomend theme_bw
scale_fill_gradientn(colours=colfunc(400)) +
guides(fill = guide_colorbar(barwidth = 0.5, barheight = 10)) +
theme(legend.title=element_blank()) +
scale_alpha_continuous(range=c(0.0, 1) , guide = FALSE) + # You can play with the range to show a better image. Range belongs to [0, 1] interval
xlim(0, 1000) + # Control lim for x-axe
ylim(0, 700) # Control lim for y-axe
print(p)
jpeg(filename = "Results/Solution4.jpeg", width = 1000, height = 700, units = "px")
print(p)
dev.off()
# E with boxes ------------------------------------------------------------