How to scale background Image in ggplot2?

My screen is of size 15.6 inches .I have taken screen shot of my screen.I am working on a project where I have to plot scatter plot of the points where mouse was clicked.So I have coordinates where the mouse was clicked .I want to plot scatter plot over this image and that scatter plot are points on the screen where mouse was clicked .So when I am plotting and the graph using the ggplot2 and adding a background image .It scales the image and the scatter points are seen at different position from where the mouse was actually clicked.

p4 <- ggplot(subset(ClickData,type1=="singleClick"), aes(ms,x=x,y=-y)) + background_image(b)+
  geom_point(alpha=1) +
  # geom_smooth(alpha=.2, size=1) +
  ggtitle("Triple click")+

How can I do this!! Thanks for answers!!

Hi, sounds as the aspect ratio could be a problem? Unfortunately, you example is nto a reproducible example since you neither provide any data nor the image source.

One idea: Try using coord_equal(ratio = 1) and play around with the ratio argument if needed.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.