Learn R Programming

rphylopic (version 0.1.9.9321)

get_image: Get data for an image or many images.

Description

Get data for an image or many images.

Usage

get_image(input, size)

Arguments

input

Either a vector of uuids or the output from the function search_images()

size

Height of the image, one of 64, 128, 256, 512, 1024, "thumb", or "icon"

See Also

search_images()

Examples

Run this code
# NOT RUN {
# input uuids
toget <- c("c089caae-43ef-4e4e-bf26-973dd4cb65c5", 
   "41b127f6-0824-4594-a941-5ff571f32378",
   "9c6af553-390c-4bdd-baeb-6992cbc540b1")
get_image(toget, size = "64")
get_image(toget, size = "thumb")

# input the output from search_images
searchres <- search_text(text = "Homo sapiens", options = "names")
output <- search_images(uuid=searchres, options=c("pngFiles", 
  "credit", "canonicalName"))
get_image(output, size = "icon")

# Put a silhouette behind a plot
library('ggplot2')
img <- get_image("27356f15-3cf8-47e8-ab41-71c6260b2724", size = "512")[[1]]
qplot(x=Sepal.Length, y=Sepal.Width, data=iris, geom="point") + 
  add_phylopic(img)

# Use as points in a ggplot plot
library('ggplot2')
uuid <- "c089caae-43ef-4e4e-bf26-973dd4cb65c5"
img <- get_image(uuid, size = "64")[[1]]
(p <- ggplot(mtcars, aes(drat, wt)) + geom_blank())
for(i in 1:nrow(mtcars)) p <- p + add_phylopic(img, 1, mtcars$drat[i], mtcars$wt[i], ysize = 0.3)
p
# }

Run the code above in your browser using DataLab