plot_pca.trajectories {tempR} | R Documentation |
Plot trajectories based on Temporal Check-All-That-Apply (TCATA) data
Description
Plot trajectories following PCA on multiblock TCATA proportions, or same for Temporal Dominance of Sensations (TDS) proportions.
Usage
plot_pca.trajectories(in.pca = in.pca, products.times = matrix(NA),
attributes = c(), type = "smooth", span = 0.75, biplot = "distance",
flip = c(FALSE, FALSE), dims = c(1, 2),
att.offset.x = c(), att.offset.y = c(), att.cex = 1, inflate.factor = NA,
xlab = "_auto_", ylab = "_auto_", xlim = NULL, ylim = NULL,
attributes.col = "red", attributes.pch = 17,
lwd = 1, traj.lab.loc = 0, traj.col = c(grDevices::grey(1/2)), traj.points = NA,
traj.col.seg = NA, traj.cex = 1, traj.lab = c(), traj.lab.cex = 1,
arrow.loc = NA, arrow.length = 0.1, arrow.col = NA, arrow.lwd = NA,
contrails = list(), main = "", save.format = "eps", save.as = "")
Arguments
in.pca |
Any |
products.times |
a 2-column matrix, with an ascending sort order on products (column 1) and a secondary ascending sort on times (column 2), corresponding to the rows of the matrix submitted to prcomp to obtain |
attributes |
a vector of attribute labels, corresponding to the attributes of the matrix submitted to prcomp to obtain |
type |
Determines how trajectories are drawn. Possible values are |
span |
A tuning parameter used if smoothing trajectories using the |
biplot |
Controls the type of biplot displayed. Possible values are |
flip |
a vector of two logical values. Value indicates whether to mirror the coordinates in the x and y dimensions respectively. Default is |
dims |
a vector of two integers, specifying the principal componts to display. Defaults is |
att.offset.x |
A vector of numeric values corresponding to the labels in |
att.offset.y |
A vector of numeric values corresponding to the labels in |
att.cex |
Attribute text size. |
inflate.factor |
Scalar controlling the position of attribute labels. If |
xlab |
Label for x axis. |
ylab |
Label for y axis. |
xlim |
Permits control of the x limit. Limits can be specified using a vector of 2 (ascending) numbers. If a single number is provided then values are selected such that the limits are 20% beyond the smallest and largest x coordinates, respectively. If unspecified then control over x axis limits is given to the plot function in R. |
ylim |
Permits control of the x limit using the same logic as is used for |
attributes.col |
Color used to display attribute labels (see |
attributes.pch |
Symbol for attribute coordinates. |
lwd |
Trajectory line width. |
traj.lab.loc |
Indicates where along the trajectory the trajectory label will be positioned. |
traj.col |
A vector of colors for trajectories. If not specified then all trajectories are shown in grey. |
traj.points |
Specifies the position of markers along smoothed trajectories, and used to indicate the progression of time. |
traj.col.seg |
A vector of colors for segments along trajectories. If |
traj.cex |
Used with |
traj.lab |
A vector of character labels that identify the trajectories. If unspecified, then products are identified by ascending natural numbers. |
traj.lab.cex |
Text size of |
arrow.loc |
Trajectory arrows locations for direction marker(s). |
arrow.length |
Trajectory arrows length. See |
arrow.col |
Trajectory arrows color. See |
arrow.lwd |
Trajectory arrows line width. See |
contrails |
list of data.frame objects with columns x, y, count, col; x and y are coordinates, count is the number of values at the coordinate, and col is the rbg colour. |
main |
plot title; see |
save.format |
If indicated, this will be the file type for the save image. Defaults to |
save.as |
The filename. Must be provided if the file will be saved. |
References
Castura, J.C., AntĂșnez, L., GimĂ©nez, A., Ares, G. (2016). Temporal check-all-that-apply (TCATA): A novel temporal sensory method for characterizing products. Food Quality and Preference, 47, 79-90. doi:10.1016/j.foodqual.2015.06.017
Castura, J.C., Baker, A.K., & Ross, C.F. (2016). Using contrails and animated sequences to visualize uncertainty in dynamic sensory profiles obtained from temporal check-all-that-apply (TCATA) data. Food Quality and Preference, 54, 90-100. doi:10.1016/j.foodqual.2016.06.011
See Also
Examples
# example using 'syrah' data set
syrah.pca <- prcomp(syrah[1:248, -c(1:4)], scale. = FALSE)
plot_pca.trajectories(syrah.pca, products.times = syrah[1:124, c(1, 4)],
attributes = colnames(syrah)[-c(1:4)], type = "raw")
# now with smoothing; may need to play with the span parameter to get appropriate smoothing
plot_pca.trajectories(syrah.pca, products.times = syrah[1:124, c(1, 4)],
attributes = colnames(syrah)[-c(1:4)], type = "smooth", span = 0.3)
# plots at each time point (trajectories join 2 points so start at timepoint 2, i.e., 11 s)
x <- 11:14 # for brevity show only the first 4 timeslices
# x <- 11:41 # uncomment this line to to run a longer demo
pca.list <- list()
for(i in seq_along(x)){
pca.list[[x[i]-10]] <- syrah.pca
pca.list[[x[i]-10]]$x <- pca.list[[x[i]-10]]$x[1:((x[i]-9)*6), ]
plot_pca.trajectories(pca.list[[x[i]-10]], products.times = syrah[1:((x[i]-9)*6), c(1, 4)],
attributes = colnames(syrah)[-c(1:4)], type = "raw", inflate.factor = 1.5)
Sys.sleep(3/4)
# save plot if saving stills for a video; see Castura, Baker, & Ross (2016, Video 1)
}