I\'m trying to plot some data over a background image. The problem is that both layers end up using the same scale. This is unfortunately problematic.
An example.<
Try this, (or alternatively annotation_raster)
library(ggplot2)
library(jpeg)
library(grid)
img <- readJPEG("image.jpg")
df <- data.frame(x=sample(1:64, 1000, replace=T),
y=sample(1:64, 1000, replace=T))
ggplot(df, aes(x,y)) +
annotation_custom(rasterGrob(img, width=unit(1,"npc"), height=unit(1,"npc")),
-Inf, Inf, -Inf, Inf) +
stat_bin2d() +
scale_x_continuous(expand=c(0,0)) +
scale_y_continuous(expand=c(0,0))