Vpyramid3d: 3d trophic level volume pyramid

Description Usage Arguments Value Examples

View source: R/Vpyramid3d.R

Description

Produces a trophic pyramid where the vertical seperations are trophic levels, with volume being biomass or (more typically) throuput. The pyramid angle is inversely proportional to the mean transfer efficiency (TEgm). V and TEgm arguments are passed to the V2Pdim function, which calculates the pyramid geometry. Output is a 3d model plotted with the rgl package.

Usage

1
2
3
Vpyramid3d(V, TEgm, col = seq(V), alpha = 0.2,
  col.bases.only = FALSE, add.scale = TRUE, scale.len = 10,
  shift = c(0, 0, 0), draw = TRUE)

Arguments

V

vector of volumes (i.e. biomass, throughput) from lowest to highest trophic level (TL). Pyramid plots usually extend to highest TL (e.g. TL 8 in EwE output). Passed to V2Pdim.

TEgm

geometric mean transfer efficiency (TLs 2-4). Passed to V2Pdim.

col

vector of colors for each volume (V). If shorter than V, colors will be cycled.

alpha

alpha of V (single value (0-1))

col.bases.only

Logical. Color bases of trophic levels only?

add.scale

logical (TRUE / FALSE) adds scale (cube) to right of box plot.

scale.len

length of side of scale cube (units of V).

shift

shift location of plot (x,y,z). Useful in comparitive plots.

draw

Logical. Produce plot (Default: draw = TRUE)

Value

rgl output

Examples

 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
### data from Tam et al (2008) - Northern Humboldt Current Ecosystem (1995-1996)

# data
TEgm <- 0.1014
Ts <- c(27165, 22349, 1658, 266.3, 17.45, 0.607, 0.00515, 6e-06)
Bs <- c(62.84, 147.1, 70.05, 20.61, 1.658, 0.084, 0.000657, 1e-06, 0)
res <- V2Pdim(V = Ts, TEgm=TEgm)
pal <- colorRampPalette(c("green", "yellow", "red"), bias=3)



# single plot of biomasses by TL
rgl::open3d()
res <- Vpyramid3d(V=Bs, TEgm = TEgm, col=pal(9), scale.len = 1)

# single plot of throughput by TL
rgl::open3d()
res <- Vpyramid3d(V=Ts[2:8], TEgm = TEgm, col=2:7, scale.len = 10)

# color bases only
rgl::open3d()
res <- Vpyramid3d(V=Ts[2:8], TEgm = TEgm, col=8, alpha=0.5, col.bases.only = TRUE, scale.len = 10)


# how to set-up a comparison plot (throughout example)
rgl::open3d()
tmp <- Vpyramid3d(V=Ts[2:8], TEgm = TEgm, alpha=0, add.scale = FALSE)
Vpyramid3d(V=Ts[2:8], TEgm = TEgm, col=2:7, 
  shift=c(dist(tmp[[1]]$vb[1,1:2])+5,0,0), scale.len = 10
)

# illustration of the effect of TEgm on top angle
rgl::open3d()
tmp <- Vpyramid3d(V=Ts[2:8], TEgm = 0.07, col=2:7, 
    add.scale = FALSE
)
tmp2 <- Vpyramid3d(V=Ts[2:8], TEgm = 0.1, col=2:7,
   shift=c(dist(tmp[[1]]$vb[1,1:2])*1.1,0,0),
   add.scale = FALSE
)
tmp3 <- Vpyramid3d(V=Ts[2:8], TEgm = 0.15, col=2:7,
  shift=c(dist(tmp[[1]]$vb[1,1:2])*1.1*2,0,0),
  add.scale = TRUE, scale.len = 1000^(1/3)
)

# add labels
pos <- data.frame(rbind(
  rowMeans(tmp[[7]]$vb),
  rowMeans(tmp2[[7]]$vb),
  rowMeans(tmp3[[7]]$vb)
))
names(pos) <- c("x", "y", "z", "w")

rgl::text3d(pos$x, y=pos$y, z = pos$z+3,
          text=paste("TE =", c("7%", "10%", "15%")),
       color="black", font=2
) 

 

marchtaylor/EwEvis documentation built on Dec. 2, 2019, 4:44 p.m.