R/plotting_functions.R
plot_by_subject.Rd
Plots all trajectories and generates density plots of position by subject from elevation and bird's eye views.
plot_by_subject(obj_name, col_by_treat = FALSE, ...)
obj_name | A viewr object (a tibble or data.frame with attribute
|
---|---|
col_by_treat | If multiple treatments or sessions, color data per
treatment or session. Treatments must be levels in a column named
|
... | Additional arguments passed to/from other pathviewR functions. |
A "bird's eye view" plot and an "elevation view" plot.
The input viewr object should have passed through
separate_trajectories()
or get_full_trajectories()
.
Optionally, treatments should have been added as levels in a column named
treatment
. Two plots will be produced, one from a "bird's eye view"
of width against length and one from an "elevation view" of height against
length. All trajectories will be plotted on a per subject basis as well as
density plots of width or height depending on the view.
col_by_treat = TRUE
, data will be plotted by color according to
treatment in both the trajectory plots and the density plots.
Other plotting functions:
plot_viewr_trajectories()
,
visualize_frame_gap_choice()
Melissa S. Armstrong
library(pathviewR) library(ggplot2) library(magrittr) if (interactive()) { ## Import the example Motive data included in the package motive_data <- read_motive_csv(system.file("extdata", "pathviewR_motive_example_data.csv", package = 'pathviewR')) ## Clean, isolate, and label trajectories motive_full <- motive_data %>% clean_viewr(desired_percent = 50, max_frame_gap = "autodetect", span = 0.95) ## Plot all trajectories by subject motive_full %>% plot_by_subject() ## Add treatment information motive_full$treatment <- c(rep("latA", 100), rep("latB", 100), rep("latA", 100), rep("latB", 149)) ## Plot all trajectories by subject, color by treatment motive_full %>% plot_by_subject(col_by_treat = TRUE) }