Skip to contents

Make a single plotly scatter plot from shared drive data

Usage

driveplot_companion(
  shareddata,
  x,
  y,
  colorvar = NULL,
  colorpalette = NULL,
  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.

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 leaflet_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".

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" )