Chapter 7 annoImage

This function can be used to add some images annotations beside the plot or in plot.

Load images:

library(jjAnno)

img1 <- system.file("extdata/animal-img/", "1.jpg", package = "jjAnno")
img2 <- system.file("extdata/animal-img/", "2.jpg", package = "jjAnno")
img3 <- system.file("extdata/animal-img/", "3.jpg", package = "jjAnno")
img4 <- system.file("extdata/animal-img/", "4.jpg", package = "jjAnno")
img5 <- system.file("extdata/animal-img/", "5.jpg", package = "jjAnno")
img6 <- system.file("extdata/animal-img/", "6.jpg", package = "jjAnno")
img7 <- system.file("extdata/animal-img/", "7.jpg", package = "jjAnno")
img8 <- system.file("extdata/animal-img/", "8.jpg", package = "jjAnno")
img9 <- system.file("extdata/animal-img/", "9.jpg", package = "jjAnno")
img10 <- system.file("extdata/animal-img/", "10.jpg", package = "jjAnno")

imgs <- c(img1,img2,img3,img4,img5,img6,img7,img8,img9,img10)

Simple annotation:

# add legend
annoImage(object = p,
          annoPos = 'top',
          xPosition = c(1:10),
          images = imgs,
          yPosition = c(11,12))

Ajust width:

# change width
annoImage(object = p,
          annoPos = 'top',
          xPosition = c(1:10),
          images = imgs,
          yPosition = c(11,11.8),
          segWidth = 0.8)

Add to right:

# add to right
annoImage(object = p,
          annoPos = 'right',
          yPosition = c(1:10),
          images = imgs,
          xPosition = c(11,11.8),
          segWidth = 0.8)

Add to botomn:

# add to botomn
annoImage(object = p,
          annoPos = 'botomn',
          xPosition = c(1:10),
          images = imgs,
          yPosition = c(-1.2,-0.4),
          segWidth = 0.8)

Annotate manually:

# annotate manually
annoImage(object = p,
          annoPos = 'right',
          yPosition = list(c(1:10),
                           c(1:10)),
          images = imgs,
          annoManual = T,
          xPosition = list(rep(c(11,11.8),each = 5),
                           rep(c(11.8,12.6),each = 5)),
          segWidth = 0.8)