driveplot_companion: Make a single plotly scatter plot from shared drive data

View source: R/driveplot_companion.R

driveplot_companionR Documentation

Make a single plotly scatter plot from shared drive data

Description

Make a single plotly scatter plot from shared drive data

Usage

driveplot_companion(
  shareddata,
  x,
  y,
  group = NULL,
  colorvar = NULL,
  colorpalette = NULL,
  fillopacity = 1,
  xlabel = NULL,
  ylabel = NULL,
  showlegend = TRUE,
  legendtitle = NULL
)

Arguments

shareddata

A SharedData object containing observations to be plotted.

x

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

y

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

group

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

colorvar

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

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 points (0 to 1).

xlabel

The label for the variable on the horizontal axis.

ylabel

The label for the variable on the vertical axis.

showlegend

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

legendtitle

The title for the plot legend.

Value

A plotly scatterplot.

Examples

library(crosstalk)
data(drive7)
shared_drive <- SharedData$new(drive7)

# Time series of speed
driveplot_companion(
  shareddata = shared_drive,
  x = time_cst,
  y = speed_mph
)

# Color points by direction of car
driveplot_companion(
  shareddata = shared_drive,
  x = time_cst,
  y = speed_mph,
  colorvar = gyro_heading,
  colorpalette = "viridis",
  xlabel = "Time",
  ylabel = "Speed (MPH)",
  showlegend = TRUE,
  legendtitle = "Gyro Heading"
)

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