Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jebyrnes/piedivplots
A function for plotting pie charts instead of points to simultaneously show diversity and composition effects in diversity-ecosystem function experiments.
https://github.com/jebyrnes/piedivplots
Last synced: 25 days ago
JSON representation
A function for plotting pie charts instead of points to simultaneously show diversity and composition effects in diversity-ecosystem function experiments.
- Host: GitHub
- URL: https://github.com/jebyrnes/piedivplots
- Owner: jebyrnes
- Created: 2013-10-17T15:31:49.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-24T21:32:14.000Z (about 11 years ago)
- Last Synced: 2024-08-06T03:05:02.692Z (3 months ago)
- Language: R
- Size: 523 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
README for pieDivPlots
========================================================A function for making plots where points are pie charts showing compositions. Code from work by Jillian Dunic wrapped into a function by Jarrett Byrnes.
```{r eval=FALSE}
#first install the multifunc library to get the data for the example
library(devtools)
install_github(multifunc, "jebyrnes")#now install some key packages if you don't have them already
install.packages("plotrix")
install.packages("RColorBrewer")
```Here's an example using data from Duffy et al. 2003
```{r fig.height=12, fig.width=16, out.height="600px", out.width="800px"}
source("./pieDivPlot.R")
library(multifunc)
data(duffy_2003)#which columns have species?
sp <- 18:23#plot the raw data
pieDivPlot(diversity, Zost_change_mass, sp,
data=duffy_2003, cex.axis=2, cex.lab=2, radius=0.1)```
To alleviate overlap, usee the jitterAmount argument as pieDivPlot can call the jitter function to spread out values on the X axis.
```{r fig.height=12, fig.width=16, out.height="600px", out.width="800px"}
set.seed(697)pieDivPlot(diversity, Zost_change_mass, sp,
data=duffy_2003, cex.axis=2, cex.lab=2, radius=0.1,
jitterAmount=0.2)
```
Or you can plot the data after aggregating it and show error bars.```{r fig.height=12, fig.width=16, out.height="600px", out.width="800px"}
#plot the aggregated data with error
library(plyr)duffy_2003_Zost <- ddply(duffy_2003, names(duffy_2003)[c(4:5,sp)], summarise,
mean_zost_change = mean(Zost_change_mass), se_zost_change = sd(Zost_change_mass)/sqrt(length(Zost_change_mass)))#for treatments with only one replicate
duffy_2003_Zost$se_zost_change[which(is.na(duffy_2003_Zost$se_zost_change))] <-0set.seed(697)
pieDivPlot(diversity, mean_zost_change, 3:8, se_zost_change,
data=duffy_2003_Zost, ylim=c(-8,13), cex.axis=2, cex.lab=2, radius=0.1, jitterAmount=0.3)abline(lm(Zost_change_mass ~ diversity, data=duffy_2003), lwd=1.5, lty=2, col="red")
```