Last active
October 24, 2018 16:04
-
-
Save roblanf/8471770 to your computer and use it in GitHub Desktop.
Make a speciesplot in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
What do you suggest?
fylopic is a good idea. I'll take a look and see what I can simplify
Cool! thanks
Looks like fylopic could allow for a search and download of a png in R, and without resorting to saving to disk.
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
this is great :) perhaps fylopic can streamline the first part of the code? http://recology.info/2013/06/fylopic/