View source: R/plotting_functions.R
plot_by_subject | R Documentation |
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. |
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, along with
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.
A "bird's eye view" plot and an "elevation view" plot, made via ggplot2.
Melissa S. Armstrong
Other plotting functions:
plot_viewr_trajectories()
,
visualize_frame_gap_choice()
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.