hermesh2
11/22/2015 - 2:29 AM

08.1 Create plot for the analysis

# S First deffine de plots ------------------------------------------------
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(breaks = list( x= seq(from = 0, to = 1000, by = 50), 
                            y = seq(from = 0, to = 800, by = 50)) ,
             colour = "gray", alpha = 0.5) +
  # stat_bin2d(bins = 10, colour = "gray", alpha = 0.5) +
  theme_bw() + # Kind of theme. I strongly recomend theme_bw
  scale_fill_gradientn(colours=colfunc(10)) +  
  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)
# E First deffine de plots ------------------------------------------------