Description Usage Arguments Value Examples
View source: R/vector_plotting.R
This wrapper function takes the data generated by pairwise.price()
and produces vector plots using either BEF, CAFE, or 5-part Price components.
1 |
data |
Pairwise Price data |
type |
Specify the type of vector diagram to draw ("cafe","bef","both", or "price") |
group.vars |
A vector of grouping variables, if any |
standardize |
Should ecosystem function values be standardized against baseline |
... |
Additional graphical options passed to lower-level functions. See |
A ggplot object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # Data setup
data(cedarcreek)
head(cedarcreek)
#Identify one grouping columns
cc2<-group_by(cedarcreek,NTrt,NAdd,Plot)
# Perform pairwise comparisons of all communities in cms identified by comm.id
# (takes ~30 sec)
pp<-pairwise.price(cc2,species='Species',func='Biomass')
# Organize/format the results, and pull out a subset using NAdd.x=0 as the control/baseline site
pp<-group.columns(pp,gps=c('NTrt','NAdd'))
pp<-pp[pp$NAdd.x=='0',]
dat1<-pp[pp$NAdd %in% c('0 27.2'),]
dat1.ctrl<-pp[pp$NAdd %in% c('0 0'),]
# Demonstrate vector plotting for comparisons between the control level of N addition (0) and the highest level of N addition (27.2):
leap.zig(dat1,type='cafe')
# Or sets of vectors grouped by N addition level:
leap.zig(pp,type='cafe',group.vars=c('NAdd.y'),raw.points=F,ylim=c(-100,700))
# The plots returned are ggplot objects, so additional design specifications can be added on:
leap.zig(dat1,type='cafe')+
ggtitle('Enrichment \n(0 vs. 27.2)')
# Control plot window
leap.zig(dat1,type='cafe',xlim=c(3,18),ylim=c(-100,700))
# Turn on errorbars associated with vector endpoints
leap.zig(dat1,type='cafe',xlim=c(3,18),ylim=c(-100,700),error.bars=T)
# Turn on/off standardization of vector magnitude (taken as % change relative to baseline)
leap.zig(dat1,type='cafe',standardize=F)
# Make a plot without showing individual points:
leap.zig(dat1,type='cafe',standardize=F,raw.points=F)
# Use other styles of vector arrangements:
leap.zig(dat1,type='bef',standardize=F,raw.points=F)
leap.zig(dat1,type='price',standardize=F,raw.points=F)
# BUSTED!
# leap.zig(dat1,type='both')
# Turn legend off
leap.zig(dat1,type='price',standardize=F,raw.points=F,legend=F)
# Combine multiple plots in separate panels
# (note: faceting currently doesn't work with leap.zig)
s1 <- leap.zig(dat1,type='cafe', xlim=c(3,18),ylim=c(-100,700),
error.bars=T,vectors=T,raw.points = F,legend=F)
s2 <- leap.zig(dat1,type='bef', xlim=c(3,18),ylim=c(-100,700),
error.bars=T,vectors=T,raw.points = F,legend=F)
library(gridExtra)
grid.arrange(s1,s2,nrow=1)
# Or on top of each other
s1 <- leap.zig(dat1,type='cafe', xlim=c(3,18),ylim=c(-100,700),
error.bars=F,vectors=T,raw.points = F,legend=F)
leap.zig(dat1.ctrl,type='cafe', xlim=c(3,18),ylim=c(-100,700),
error.bars=F,vectors=T,raw.points = F,legend=F,
add=T,old.plot=s1)
# BUSTED - due to conflicting color scales
# s1 <- leap.zig(dat1,type='cafe', xlim=c(3,18),ylim=c(-100,700),
# error.bars=T,vectors=T,raw.points = F,legend=F)
# leap.zig(dat1,type='bef', xlim=c(3,18),ylim=c(-100,700),
# error.bars=T,vectors=T,raw.points = F,legend=F,
# add=T,old.plot=s1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.