tcsplot: Interactive plot of a tetrahedral colourspace

View source: R/tcsplot.R

tcsplotR Documentation

Interactive plot of a tetrahedral colourspace

Description

Produces an interactive 3D plot of a tetrahedral colourspace using OpenGL capabilities.

Plots points in a tetrahedral colour space

Usage

tcsplot(
  tcsdata,
  size = 0.02,
  alpha = 1,
  col = "black",
  vertexsize = 0.02,
  achro = TRUE,
  achrosize = 0.01,
  achrocol = "grey",
  lwd = 1,
  lcol = "lightgrey",
  new = FALSE,
  hspin = FALSE,
  vspin = FALSE,
  floor = TRUE,
  gamut = FALSE
)

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

tcsvol(
  tcsdata,
  type = c("convex", "alpha"),
  avalue = "auto",
  col = "black",
  alpha = 0.2,
  grid.alpha = 1,
  grid = TRUE,
  fill = TRUE,
  lwd = 1
)

Arguments

tcsdata

(required) a data frame, possibly a result from the colspace() or tcspace() 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)

alpha

transparency of points (or volume fill in tcsvol())

col

colour of the points in the plot (defaults to black)

vertexsize

size of the points at the vertices

achro

should a point be plotted at the origin (defaults to TRUE)?

achrosize

size of the point at the origin when achro = TRUE (defaults to 0.8).

achrocol

color of the point at the origin achro = TRUE (defaults to 'grey').

lwd, lcol

graphical parameters for the edges of the tetrahedron.

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)

gamut

logical. Should the polygon showing the possible colours given visual system and illuminant used in the analysis (defaults to FALSE). This option currently only works when qcatch = Qi.

type

accepts a vector of length 1 or 2 with 'p' for points and/or 'l' for lines from the point to the base of the tetrahedron.

avalue

if type = "alpha", which alpha parameter value should be used to compute the alphashape. avalue = "auto" (default) finds and use the \alpha^* value as defined in Gruson (2020).

grid.alpha

transparency of the volume polygon grid lines

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).

tcspoints() adds points to the plot. Points are currently plotted only as spheres to maintain export capabilities.

tcsvol() creates a 3D colour volume within a tcsplot object.

Author(s)

Rafael Maia rm72@zips.uakron.edu

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.

Examples


# For plotting
data(sicalis)
vis.sicalis <- vismodel(sicalis, visual = "avg.uv")
tcs.sicalis <- colspace(vis.sicalis, space = "tcs")
tcsplot(tcs.sicalis, size = 0.005)
rgl::rgl.postscript("testplot.pdf", fmt = "pdf")
rgl::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 = 0.005)
tcsvol(tcs.sicalis)


pavo documentation built on Sept. 24, 2023, 5:06 p.m.