Skip to content

Instantly share code, notes, and snippets.

@roblanf
Last active October 24, 2018 16:04
Show Gist options
  • Save roblanf/8471770 to your computer and use it in GitHub Desktop.
Save roblanf/8471770 to your computer and use it in GitHub Desktop.
Make a speciesplot in R
# Create a scatterplot with any species as the data points.
# To choose your species, go here: http://phylopic.org/ , then enter the name of the spp you want. Click on the image and click 'thumbnail', click on the picture, and then copy the link in the address bar of your browser. It should end with 'thumb.png' Paste it in place of the link below.
library(TeachingDemos)
library(png)
# Paste a link to a png of your favourite animal here. This will be an aardvarkplot. Make sure it ends with .thumb.png.
# If it doesn't end with .thumb.png reread the instructions above and try again.
link = "http://phylopic.org/assets/images/submissions/cfee2dca-3767-46b8-8d03-bd8f46e79e9e.thumb.png"
# the rest is sweet magic
download.file(link, destfile = "pic.png")
img <- readPNG(source = "pic.png")
my.symbols( runif(10), runif(10), ms.image, MoreArgs=list(img=img), inches=0.5, symb.plots=TRUE, add=FALSE, xlab = 'Aardvark', ylab = 'Aardvark', xlim = c(0.0, 1.0), ylim = c(0.0, 1.0))
# @aardvarkwizard requested some termites, we can do that with add = TRUE. Hope they like Mastotermes darwiniensis Froggatt 1897
termite.link = "http://phylopic.org/assets/images/submissions/c44be6d9-6398-4753-84db-9609760fd37c.thumb.png"
download.file(termite.link, destfile = "termite.png")
img <- readPNG(source = "termite.png")
my.symbols( runif(20), runif(20), ms.image, MoreArgs=list(img=img), inches=0.2, symb.plots=TRUE, add=TRUE)
@karthik
Copy link

karthik commented Jan 28, 2014

You can also add it to a legend. See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment