This question already has an answer here:
- Overlay data onto background image 3 answers
I made a plot with a 3 million points and saved it as PNG. It took a few hours and I would like to avoid re-drawing all the points.
How can I generate a new plot that has this PNG as a background?
Try this:
Below is the plot.
While @bill_080's answer directly answers your question, is this really what you want? If you want to plot onto this, you'll have to carefully align your coordinate systems. See e.g. Houston Crime Map how this can be done with ggplot2.
For your problem, it seems to me that there may be an easier solution: binning, i.e. ceating 2d histograms.
hexbin works directly with lattice and ggplot2, but the center coordinates of the bins are in
binned@xcm
andbinned@ycm
, so you could also plot the result in base graphics. With high number of bins, you get a fast version of your original plot:but you can easily have the colours coding the density: