dplot3_ts: Interactive Timeseries Plots

View source: R/dplot3_ts.R

dplot3_tsR Documentation

Interactive Timeseries Plots

Description

Draw interactive timeseries plots using plotly

Usage

dplot3_ts(
  x,
  time,
  window = 7L,
  group = NULL,
  roll.fn = c("mean", "median", "max", "none"),
  roll.col = NULL,
  roll.alpha = 1,
  roll.lwd = 2,
  roll.name = NULL,
  alpha = NULL,
  align = "center",
  group.names = NULL,
  xlab = "Time",
  n.xticks = 12,
  scatter.type = "scatter",
  legend = TRUE,
  x.showspikes = TRUE,
  y.showspikes = FALSE,
  spikedash = "solid",
  spikemode = "across",
  spikesnap = "hovered data",
  spikecolor = NULL,
  spikethickness = 1,
  displayModeBar = TRUE,
  modeBar.file.format = "svg",
  theme = rtTheme,
  palette = rtPalette,
  filename = NULL,
  file.width = 500,
  file.height = 500,
  file.scale = 1,
  ...
)

Arguments

x

Numeric vector of values to plot or list of vectors

time

Numeric or Date vector of time corresponding to values of x

window

Integer: apply roll.fn over this many units of time

group

Factor defining groups

roll.fn

Character: "mean", "median", "max", or "sum": Function to apply on rolling windows of x

roll.col

Color for rolling line

roll.alpha

Numeric: transparency for rolling line

roll.lwd

Numeric: width of rolling line

roll.name

Rolling function name (for annotation)

alpha

Numeric [0, 1]: Transparency

align

Character: "center", "right", or "left"

group.names

Character vector of group names

xlab

Character: x-axis label

n.xticks

Integer: number of x-axis ticks to use (approximately)

scatter.type

Character: "scatter" or "lines"

legend

Logical: If TRUE, show legend

x.showspikes

Logical: If TRUE, show x-axis spikes on hover

y.showspikes

Logical: If TRUE, show y-axis spikes on hover

spikedash

Character: dash type string ("solid", "dot", "dash", "longdash", "dashdot", or "longdashdot") or a dash length list in px (eg "5px,10px,2px,2px")

spikemode

Character: If "toaxis", spike line is drawn from the data point to the axis the series is plotted on. If "across", the line is drawn across the entire plot area, and supercedes "toaxis". If "marker", then a marker dot is drawn on the axis the series is plotted on

spikesnap

Character: "data", "cursor", "hovered data". Determines whether spikelines are stuck to the cursor or to the closest datapoints.

spikecolor

Color for spike lines

spikethickness

Numeric: spike line thickness

displayModeBar

Logical: If TRUE, display plotly's modebar

modeBar.file.format

Character: modeBar image export file format

theme

Character: theme name or list of theme parameters

palette

Character: palette name, or list of colors

filename

Character: Path to filename to save plot

file.width

Numeric: image export width

file.height

Numeric: image export height

file.scale

Numeric: image export scale

...

Additional arguments to be passed to dplot3_xy

Author(s)

E.D. Gennatas

Examples

## Not run: 
time <- sample(seq(as.Date("2020-03-01"), as.Date("2020-09-23"), length.out = 140))
x1 <- rnorm(140)
x2 <- rnorm(140, 1, 1.2)
# Single timeseries
dplot3_ts(x1, time)
# Multiple timeseries input as list
dplot3_ts(list(Alpha = x1, Beta = x2), time)
# Multiple timeseries grouped by group, different lengths
time1 <- sample(seq(as.Date("2020-03-01"), as.Date("2020-07-23"), length.out = 100))
time2 <- sample(seq(as.Date("2020-05-01"), as.Date("2020-09-23"), length.out = 140))
time <- c(time1, time2)
x <- c(rnorm(100), rnorm(140, 1, 1.5))
group <- c(rep("Alpha", 100), rep("Beta", 140))
dplot3_ts(x, time, 7, group)

## End(Not run)


egenn/rtemis documentation built on May 4, 2024, 7:40 p.m.