Required packets: ggplot2, png, grid

Load tutorial data set.

total<- read.csv("data.csv", header = TRUE)

Create a basic plot with X and Y coordinates.

p <-ggplot(total, aes(x=x,y=y)) +
geom_point()
p 

Next, import an image that you want as a background.

my_image <-  readPNG("image.png")

Now you’ll need to convert the image to a raster.

g <- rasterGrob(my_image, interpolate=TRUE) 

Add the background image to the plot.

# Create a basic plot
p <-ggplot(total, aes(x=x,y=y)) +
annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)+
geom_point()
p