Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 3 months ago
JSON representation

A function for plotting pie charts instead of points to simultaneously show diversity and composition effects in diversity-ecosystem function experiments.

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))] <-0

set.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")
```