Learn R Programming

pavo (version 0.3-1)

tcsplot: Plot a Tetrahedral Color Space

Description

tcsplot produces a 3D plot of a tetrahedral color space using OpenGL capabilities

tcspoints plots points in a tetrahedral color space

tcsvol produces a 3D convex hull in tetrahedral color space

Usage

tcsplot(tcsdata, size = 0.02, col = "black", new = FALSE,
    hspin = FALSE, vspin = FALSE, floor = TRUE,
    grid = TRUE, fill = TRUE)

tcspoints(tcsdata, size = 0.02, col = "black")

tcsvol(tcsdata, col = "black", grid = T, fill = T)

Arguments

tcsdata
(required) a data frame, possibly a result from the tcs function, containing values for the 'x', 'y' and 'z' coordinates as columns (labeled as such)
size
size of the points in the plot (defaults to 0.02)
col
color of the points in the plot (defaults to black)
new
should a new 3D plot be called (defaults to FALSE)?
hspin
if TRUE, the graphic will spin horizontally (around the 'z' axis)(defaults to FALSE).
vspin
if TRUE, the graphic will spin vertically (around the 'x' axis)(defaults to FALSE).
floor
if TRUE, a reference xy plane is plotted under the tetrahedron (defaults to TRUE).
grid
if TRUE, connects the polygon outlining the volume occupied by points (defaults to TRUE).
fill
if TRUE, fills the volume occupied by points (WARNING: transparency is not saved properly if exported using rgl.postscript)(defaults to TRUE).

Value

  • tcsplot creates a 3D plot using functions of the package rgl, based on openGL capabilities. Plot is interactive and can be manipulated with the mouse (left button: rotate along 'z' axis; right button: rotate along 'x' axis; third button: zoom). tcsvol creates polygon based on points, determining the volume occupied by them in the colorspace. tcspoints adds points to the plot. Points are currently plotted only as spheres to maintain export capabilities.

    tcspoints creates 3D points in a tetrahedral color space plot produced by tcsplot using functions of the package rgl, based on openGL capabilities.

    tcsvol creates a 3D convex hull within a tcsplot object

References

Stoddard, M. C., & Prum, R. O. (2008). Evolution of avian plumage color in a tetrahedral color space: A phylogenetic analysis of new world buntings. The American Naturalist, 171(6), 755-776.

Endler, J. A., & Mielke, P. (2005). Comparing entire colour patterns as birds see them. Biological Journal Of The Linnean Society, 86(4), 405-431.

See Also

spheres3d,rgl.postscript, rgl.snapshot,rgl.material

Examples

Run this code
# For plotting
data(sicalis)
vis.sicalis <- vismodel(sicalis, visual='avg.uv')
tcs.sicalis <- tcs(vis.sicalis)
tcsplot(tcs.sicalis, size=0.005)
rgl.postscript('testplot.pdf',fmt='pdf')
rgl.snapshot('testplot.png')

# For adding points
patch <- rep(c('C','T','B'),7)
tcs.crown <- subset(tcs.sicalis, 'C')
tcs.breast <- subset(tcs.sicalis, 'B')
tcsplot(tcs.crown, col='blue')
tcspoints(tcs.breast, col='red')

# For plotting convex hull
tcsplot(tcs.sicalis, col='blue', size=.005)
tcsvol(tcs.sicalis)

Run the code above in your browser using DataLab