1

I am trying to create a snakes & ladders board. I have found an image online that I wish to use as a background, but I have been unable to do so. The rimages package suggested in this solution was removed from CRAN. Also if someone could show me how to remove x & y axis' from the final image it would be great.

The link for the .jpg is:

http://images8.alphacoders.com/448/448009.jpg

The plot code that I am using is

plot(x, y, pch=19, cex=5, col='red', xlim=c(0, 6), ylim=c(0, 5))
jay.sf
  • 60,139
  • 8
  • 53
  • 110
  • adding `axes = F` to your plot call will turn off the axis plotting. As to plotting on top of an image, I think you're a duplicate of [this question](http://stackoverflow.com/q/4993189/903061). – Gregor Thomas Jul 14 '15 at 21:07
  • Thanks Gregor, I had previously found that solution but unfortunately the 'rimages' package has been removed from cran – Colm McGarvey Jul 14 '15 at 21:25
  • Oh, I thought the problem was plotting, not reading in the image. See the help for `jpeg::readJPEG`, the examples should get you there. – Gregor Thomas Jul 14 '15 at 22:19

1 Answers1

3

Use readJPEG from the jpeg library to read your jpeg; use rasterImage to plot it

# download your jpeg file, save it to read in (jpeg package doesn't
#  download from URL)
download.file('http://images8.alphacoders.com/448/448009.jpg', destfile='bg.jpg')
library(jpeg)
jp <- readJPEG('bg.jpg')

# plot background. coordinates are same as your x/y scale.
rasterImage(jp, xleft=0, xright=6, ybottom=0, ytop=5)

# plot dots on top
x <- sample(6, 10, replace=T)-.5
y <- sample(5, 10, replace=T)-.5
points(x,y, pch=19, cex=5, col='black', xlim=c( 0, 6),ylim=c( 0, 5))

enter image description here

mathematical.coffee
  • 55,977
  • 11
  • 154
  • 194