Skip to contents

Function used to plot trajectories

Usage

ena.plot.trajectory(
  enaplot,
  points,
  by = NULL,
  labels = NULL,
  labels.show = c("Always", "Hover", "Both"),
  names = NULL,
  label.offset = NULL,
  label.font.size = enaplot$get("font.size"),
  label.font.color = enaplot$get("font.color"),
  label.font.family = c("Arial", "Courier New", "Times New Roman"),
  shape = c("circle", "square", "triangle-up", "diamond"),
  colors = NULL,
  default.hidden = FALSE,
  smooth = c("none", "poly"),
  poly.degree = NULL,
  poly.max.degree = 3L,
  poly.criterion = c("loocv", "aic"),
  poly.n.eval = 200L,
  show.points = TRUE,
  show.curve = TRUE
)

Arguments

enaplot

ENAplot object to use for plotting

points

dataframe of matrix - first two column are X and Y coordinates, each row is a point in a trajectory

by

vector used to subset points into individual trajectories, length nrow(points)

labels

character vector - point labels, length nrow(points)

labels.show

A character choice: Always, Hover, Both. Default: Both

names

character vector - labels for each trajectory of points, length length(unique(by))

label.offset

A numeric vector of an x and y value to offset labels from the coordinates of the points

label.font.size

An integer which determines the font size for labels, default: enaplot$font.size

label.font.color

A character which determines the color of label font, default: enaplot$font.color

label.font.family

A character which determines font type, choices: Arial, Courier New, Times New Roman, default: enaplot$font.family

shape

A character which determines the shape of markers, choices: square, triangle, diamond, circle, default: circle

colors

A character vector, that determines marker color, default NULL results in alternating random colors. If single color is supplied, it will be used for all trajectories, otherwise the length of the supplied color vector should be equal to the length of the supplied names (i.e a color for each trajectory being plotted)

default.hidden

A logical indicating if the trajectories should start hidden (click on the legend to show them) Default: FALSE

smooth

Character choice: "none" (connect discrete points) or "poly" (fit orthogonal polynomial curve with LOOCV-2D). Default: "none"

poly.degree

Fixed integer polynomial degree (default NULL = auto-select via LOOCV-2D / AIC)

poly.max.degree

Maximum polynomial degree to search when auto-selecting (default: 3)

poly.criterion

Criterion for polynomial degree selection: "loocv" or "aic"

poly.n.eval

Number of evaluation points along the curve (default: 200)

show.points

Logical: whether to display original discrete points when smooth = "poly" (default: TRUE)

show.curve

Logical: whether to display smooth polynomial curve when smooth = "poly" (default: TRUE)

Value

The ENAplot provided to the function, with its plot updated to include the trajectories #####

See also

Examples

data(RS.data)

codeNames = c('Data','Technical.Constraints','Performance.Parameters',
  'Client.and.Consultant.Requests','Design.Reasoning','Collaboration');

accum = ena.accumulate.data(
  units = RS.data[,c("UserName","Condition")],
  conversation = RS.data[,c("GroupName","ActivityNumber")],
  metadata = RS.data[,c("CONFIDENCE.Change","CONFIDENCE.Pre","CONFIDENCE.Post","C.Change")],
  codes = RS.data[,codeNames],
  window.size.back = 4,
  model = "A"
);

set = ena.make.set(accum);

### get mean network plots
first.game.lineweights = as.matrix(set$line.weights$Condition$FirstGame)
first.game.mean = colMeans(first.game.lineweights)

second.game.lineweights = as.matrix(set$line.weights$Condition$SecondGame)
second.game.mean = colMeans(second.game.lineweights)

subtracted.network = first.game.mean - second.game.mean

# Plot dimension 1 against ActivityNumber metadata
dim.by.activity = cbind(
    as.matrix(set$points)[,1],
    set$trajectories$ActivityNumber * .8/14-.4  #scale down to dimension 1
)

plot = ena.plot(set)
plot = ena.plot.network(plot, network = subtracted.network, legend.name="Network")
plot = ena.plot.trajectory(
  plot,
  points = dim.by.activity,
  names = unique(set$model$unit.label),
  by = set$trajectories$ENA_UNIT
);
print(plot)