driveplot: Create a vehicle trajectory plot map

View source: R/driveplot.R

driveplotR Documentation

Create a vehicle trajectory plot map

Description

Create a vehicle trajectory plot map

Usage

driveplot(
  shareddata,
  lng = NULL,
  lat = NULL,
  x,
  ys,
  group = NULL,
  colorvar = NULL,
  maplabel = NA,
  colorpalette = NULL,
  fillopacity = 1,
  xlabel = NULL,
  ylabels = NULL,
  showlegend = TRUE,
  legendtitle = NULL,
  plottitle = NULL,
  spacing = 0.05,
  width = "100%",
  height = "100vh",
  tileprovider = "Esri.WorldStreetMap"
)

Arguments

shareddata

A SharedData object containing observations to be plotted.

lng

The bare (unquoted) column of shareddata containing longitude (only required if shareddata does not have a geometry column).

lat

The bare (unquoted) column of shareddata containing latitude (only required if shareddata does not have a geometry column)

x

The bare (unquoted) column from shareddata to be plotted on the horizontal axis.

ys

A vector or list of bare (unquoted) columns from shareddata to be plotted on the vertical axes of the companion graphs.

group

The bare (unquoted) column from shareddata for the grouping variable.

colorvar

The bare (unquoted) column in shareddata to which color should be mapped.

maplabel

An optional label for the map points.

colorpalette

The color palette for the plot; either a single color (e.g., "red") or one of the viridis color palettes compatible with leaflet. Run viridis_color_palettes() to see the available options for viridis color palettes. If colorvar and colorpalette are both not provided, colorpalette defaults to blue. If colorvar is provided but colorpalette is not, colorpalette defaults to the color palette "viridis".

fillopacity

The opacity of the fill of the map points (0 to 1).

xlabel

The label for the variable on the horizontal axis.

ylabels

A vector or list of labels for the vertical axes of the companion graphs. If provided, it should be the same length as ys.

showlegend

Show the plot legend (TRUE) or not (FALSE).

legendtitle

The title for the plot legend.

plottitle

The title for the plot map.

spacing

A value between 0 and 1 for the space between the companion graphs.

width

The width of the plot map, provided as a string with one of the following units: %, vh, vw, or px (e.g., "100%" or "400px")

height

The height of the plot map, provided as a string with one of the following units: %, vh, vw, or px (e.g., "100%" or "400px").

tileprovider

The name of the provider for the basemap tiles. Options can be found by running leaflet::providers. Defaults to "Esri.WorldStreetMap".

Value

A linked plot map.

Examples

## Only run examples in interactive R sessions
if (interactive()) {
library(crosstalk)
data(drive7)
shared_drive <- SharedData$new(drive7)

driveplot(
  shareddata = shared_drive,
  x = time_cst,
  ys = c(speed_mph, gyro_heading, gps_heading),
  colorvar = gyro_heading,
  maplabel = time_cst,
  colorpalette = "viridis",
  fillopacity = 1,
  xlabel = "Time",
  ylabels = c(
    "Speed (mph)", "Gyro Heading (degrees)",
    "GPS Heading (degrees)"
  ),
  showlegend = TRUE,
  legendtitle = "Gyro Heading",
  plottitle = "A drive with points colored by gyro heading",
  height = "500px"
)
}

DrivePlotR documentation built on Nov. 22, 2026, 5:06 p.m.