Placing Custom Images in a Plot Window--as custom data markers or to annotate those markers

前端 未结 5 1416
谎友^
谎友^ 2020-12-01 00:19

I have a set of 150x150px png images, and a set of (x, y) coordinates that they correspond to. Is there a way to plot the images on a grid? For example, I\'m looking for an

5条回答
  •  粉色の甜心
    2020-12-01 01:05

    One way to do it in R (2.11.0 and higher):

    library("png")
    # read a sample file (R logo)
    img <- readPNG(system.file("img", "Rlogo.png", package="png"))
    # img2 <- readPNG(system.file("img", "Rlogo.png", package="png"))
    img2 <- readPNG("hand.png", TRUE) # here import a different image 
    if (exists("rasterImage")) { 
      plot(1:1000, type='n')
      rasterImage(img, 100, 100, 200, 200)
      rasterImage(img2, 300, 300, 400, 400)
    }
    

    see ?readPNG and ?rasterImage for details. enter image description here

提交回复
热议问题