[R] Soil texture triangle in R?

Sander Oom slist at oomvanlieshout.net
Fri May 27 15:42:43 CEST 2005


Hi Jari,

I assume this has been superseded by the ternaryplot{vcd} function!?

Thanks,

Sander.

Jari Oksanen wrote:
 > Sander,
 >
 > Just a quick note before I go to the field.
 >
 > I attach a tri.R file for drawing ternary plots. The base function was
 > posted to R News someday. One thing that I added was option to plot
 > nothing (type="n") plus (invisible) return of plotting coordinates. This
 > means that you can take the coordinates for drawing segments (in
 > original values), feed them through this functions, and you get
 > translated coordinates to use ordinary segments or lines commands to
 > overlay your lines into an existing ternary plot.
 >
 > We used this in an Applied Vegetation Science paper (Hellström as the
 > first author) to overlay arrows onto ternary plots.
 >
 > cheers, jari oksanen
 >
 >
 > ------------------------------------------------------------------------
 >
 > "tri" <-
 >     function(a, f, m, symb = 2, grid = F, ...)
 > {
 >     ta <- paste(substitute(a))
 >     tf <- paste(substitute(f))
 >     tm <- paste(substitute(m))
 >
 >     tot <- 100/(a + f +m)
 >     b <- f * tot
 >     y <- b * .878
 >     x <- m * tot + b/2
 >     par(pty = "s")
 >     oldcol <- par("col")
 >     plot(x, y, axes = F, xlab = "", ylab = "", xlim = c(-10, 110), ylim
 >          = c(-10, 110), type = "n", ...)
 >     points(x,y,pch=symb)
 >     par(col = oldcol)
 >     trigrid(grid)
 >     text(-5, -5, ta)
 >     text(105, -5, tm)
 >     text(50, 93, tf)
 >     par(pty = "m")
 >     invisible(cbind(x,y))
 > }
 >




More information about the R-help mailing list