Created
May 12, 2014 17:35
-
-
Save fmichonneau/9c4eb25aebb87c34e48b to your computer and use it in GitHub Desktop.
Code to reproduce the mean weight per species using the Zissou color palette (from #datacarpentry tweet)
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
## Code to reproduce: https://twitter.com/FrancoisInvert/status/464493646151446528 | |
library(wesanderson) # for the Zissou palette | |
library(RCurl) # needed to get data with HTTPS protocol | |
rodentURL <- getURL("https://raw.githubusercontent.com/NESCent/2014-05-08-datacarpentry/master/data/surveys.csv") | |
rodentData <- read.csv(textConnection(rodentURL)) | |
meanPerSpecies <- aggregate(wgt ~ species, data=rodentData, mean, na.rm=TRUE) | |
zissouPal <- wes.palette(name = "Zissou", type="continuous") | |
png(file="zissouRodent.png", width=657, heigh=348) | |
par(mar=c(4, 2, 0, 1)) # if you want to see the legend | |
## par(mar=c(2, 2, 0, 1)) # for twitter (without legend) | |
barplot(sort(meanPerSpecies$wgt), horiz=TRUE, las=1, | |
col=zissouPal(nlevels(meanPerSpecies$species[, drop=TRUE])), | |
names.arg=meanPerSpecies$species, xlab="Mean weight (g)", | |
cex.names=.7, cex.axis=.7) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment