subplotly: Plot multi-trace subplots with plotly.

Description Usage Arguments Details Value Examples

View source: R/plot_aggregates.R

Description

subplotly plots multi-trace subplots with plotly.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
subplotly(
  df,
  in_var,
  de_var,
  groupby_var = NULL,
  plot_type = list(type = "scatter", mode = "lines"),
  orientation = c("v", "h"),
  margin = 0.02,
  return_type = c("subplot", "list")
)

Arguments

df

A data.frame.

in_var

A character or (named) charactor vector. Character of the columns to be used for independent variable, typically x axis in "vertical" orientation.

de_var

A character, or (named) charactor vector, or (named) list of character vector. The structure will determine how the dependent variables are arranged into multi-axis subplots, typically y axis in "vertical" orientation.

groupby_var

A character, or character vector. Character of the column(s) to be used for grouping, currently implemented by linetype.

plot_type

Named list for plotly type, mode, etc.

orientation

"v" or "h", for "vertical" and "horizontal". v (vertical) is the common x/y arrangement e.g. top edge, h (horizontal) is the uncommon x/y arrangement e.g. right edge.

margin

float. margin argument in subplot call.

return_type

"subplot" or "list". return_type should be subplot or list of plots.

Details

This is a function to plot multi-trace subplots using plotly package. Multiple dependent variables are plot agains multiple independent variables. Dependent variables can be organized/combined in different subplots. Groupby variable and plot types can be controlled. The plots can be both vertical (default) and horizontal orientations. It can return either subplots or a list of plotly objects.

Value

A plotly (subplot) object or a list of plotly objects depending on return_type. The subplot is ncol = length(in_var), nrow = length(de_var)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
subplotly(df,
  in_var = c("x_column1", "x_column2"),
  de_var = c("y_column1", "y_column2"),
  groupby_var = "z_column",
  plot_type = list(type = "scatter", mode = "lines"),
  margin = 0.02,
  orientation = "v", return_type = "subplot")

## End(Not run)

xiangnandang/rsubplotly documentation built on May 6, 2020, 12:37 a.m.