dplot3_x: Interactive Univariate Plots

View source: R/dplot3_x.R

dplot3_xR Documentation

Interactive Univariate Plots

Description

Draw interactive univariate plots using plotly

Usage

dplot3_x(
  x,
  type = c("density", "histogram"),
  mode = c("overlap", "ridge"),
  group = NULL,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  col = NULL,
  alpha = 0.75,
  plot.bg = NULL,
  theme = rtTheme,
  palette = rtPalette,
  axes.square = FALSE,
  group.names = NULL,
  font.size = 16,
  font.alpha = 0.8,
  legend = NULL,
  legend.xy = c(0, 1),
  legend.col = NULL,
  legend.bg = "#FFFFFF00",
  legend.border.col = "#FFFFFF00",
  bargap = 0.05,
  vline = NULL,
  vline.col = theme$fg,
  vline.width = 1,
  vline.dash = "dot",
  text = NULL,
  text.x = 1,
  text.xref = "paper",
  text.xanchor = "left",
  text.y = 1,
  text.yref = "paper",
  text.yanchor = "top",
  text.col = theme$fg,
  margin = list(b = 65, l = 65, t = 50, r = 10, pad = 0),
  automargin.x = TRUE,
  automargin.y = TRUE,
  zerolines = FALSE,
  density.kernel = "gaussian",
  density.bw = "SJ",
  histnorm = c("", "density", "percent", "probability", "probability density"),
  histfunc = c("count", "sum", "avg", "min", "max"),
  hist.n.bins = 20,
  barmode = "overlay",
  ridge.sharex = TRUE,
  ridge.y.labs = FALSE,
  ridge.order.on.mean = TRUE,
  displayModeBar = TRUE,
  modeBar.file.format = "svg",
  width = NULL,
  height = NULL,
  filename = NULL,
  file.width = 500,
  file.height = 500,
  file.scale = 1,
  ...
)

Arguments

x

Numeric, vector / data.frame /list: Input. If not a vector, each column of or each element

type

Character: "density" or "histogram"

mode

Character: "overlap", "ridge". How to plot different groups; on the same axes ("overlap"), or on separate plots with the same x-axis ("ridge")

group

Vector: Will be converted to factor; levels define group members. Default = NULL

main

Character: Main plot title.

xlab

Character: x-axis label.

ylab

Character: y-axis label.

col

Color, vector: Color for bars. Default NULL, which will draw colors from palette

alpha

Float (0, 1]: Transparency for bar colors. Default = .8

plot.bg

Color: Background color for plot area

theme

List or Character: Either the output of a ⁠theme_*()⁠ function or the name of a theme. Use themes() to get available theme names. Theme functions are of the form ⁠theme_<name>⁠.

palette

Character: Name of rtemis palette to use. Default = "rtCol1". Only used if col = NULL

axes.square

Logical: If TRUE: draw a square plot to fill the graphic device. Default = FALSE. Note: If TRUE, the device size at time of call is captured and height and width are set so as to draw the largest square available. This means that resizing the device window will not automatically resize the plot.

group.names

Character, vector, length = NROW(x): Group names. Default = NULL, which uses rownames(x)

font.size

Float: Font size for all labels. Default = 16

font.alpha

Float: Alpha transparency for font.

legend

Logical: If TRUE, draw legend. Default = NULL, which will be set to TRUE if x is a list of more than 1 element

legend.xy

Float, vector, length 2: Relative x, y position for legend. Default = c(0, 1), which places the legend top left within the plot area. Set to NULL to place legend top right beside the plot area

legend.col

Color: Legend text color. Default = NULL, determined by theme

legend.bg

Color: Background color for legend

legend.border.col

Color: Border color for legend

bargap

Float: The gap between adjacent histogram bars in plot fraction.

vline

Float, vector: If defined, draw a vertical line at this x value(s). Default = NULL

vline.col

Color for vline. Default = theme$fg

vline.width

Float: Width for vline. Default = 1

vline.dash

Character: Type of line to draw: "solid", "dot", "dash", "longdash", "dashdot", or "longdashdot"

text

Character: If defined, add this text over the plot

text.x

Float: x-coordinate for text

text.xref

Character: "x": text.x refers to plot's x-axis; "paper": text.x refers to plotting area from 0-1

text.xanchor

Character: "auto", "left", "center", "right"

text.y

Float: y-coordinate for text

text.yref

Character: "y": text.y refers to plot's y-axis; "paper": text.y refers to plotting area from 0-1

text.yanchor

Character: "auto", "top", "middle", "bottom"

text.col

Color for text. Default = theme$fg

margin

Named list: plot margins.

automargin.x

Logical: If TRUE, automatically set x-axis amrgins

automargin.y

Logical: If TRUE, automatically set y-axis amrgins

zerolines

Logical: If TRUE, draw lines at y = 0.

density.kernel

Character: Kernel to use for density estimation.

density.bw

Character: Bandwidth to use for density estimation.

histnorm

Character: NULL, "percent", "probability", "density", "probability density"

histfunc

Character: "count", "sum", "avg", "min", "max".

hist.n.bins

Integer: Number of bins to use if type = "histogram".

barmode

Character: Type of bar plot to make: "group", "relative", "stack", "overlay". Default = "group". Use "relative" for stacked bars, wich handles negative values correctly, unlike "stack", as of writing.

ridge.sharex

Logical: If TRUE, draw single x-axis when mode = "ridge".

ridge.y.labs

Lofical: If TRUE, show individual y labs when mode = "ridge".

ridge.order.on.mean

Logical: If TRUE, order groups by mean value when mode = "ridge". Turn to FALSE, if, for example, groups are ordered by date or similar.

displayModeBar

Logical: If TRUE, show plotly's modebar

modeBar.file.format

Character: "svg", "png", "jpeg", "pdf" / any output file type supported by plotly and your system

width

Float: Force plot size to this width. Default = NULL, i.e. fill available space

height

Float: Force plot size to this height. Default = NULL, i.e. fill available space

filename

Character: Path to file to save static plot.

file.width

Integer: File width in pixels for when filename is set.

file.height

Integer: File height in pixels for when filename is set.

file.scale

Numeric: If saving to file, scale plot by this number

...

Additional arguments passed to theme function.

Details

If input is data.frame, non-numeric variables will be removed

Value

A plotly object

Author(s)

E.D. Gennatas

Examples

## Not run: 
dplot3_x(iris)
dplot3_x(split(iris$Sepal.Length, iris$Species), xlab = "Sepal Length")

## End(Not run)


egenn/rtemis documentation built on Nov. 22, 2024, 4:12 a.m.