dplot3_bar: Interactive Barplots

View source: R/dplot3_bar.R

dplot3_barR Documentation

Interactive Barplots

Description

Draw interactive barplots using plotly

Usage

dplot3_bar(
  x,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  col = NULL,
  alpha = 1,
  horizontal = FALSE,
  theme = rtTheme,
  palette = rtPalette,
  barmode = c("group", "relative", "stack", "overlay"),
  group.names = NULL,
  order.by.val = FALSE,
  ylim = NULL,
  hovernames = NULL,
  feature.names = NULL,
  font.size = 16,
  annotate = FALSE,
  annotate.col = theme$labs.col,
  legend = NULL,
  legend.col = NULL,
  legend.xy = c(1, 1),
  legend.orientation = "v",
  legend.xanchor = "left",
  legend.yanchor = "auto",
  hline = NULL,
  hline.col = NULL,
  hline.width = 1,
  hline.dash = "solid",
  hline.annotate = NULL,
  hline.annotation.x = 1,
  margin = list(b = 65, l = 65, t = 50, r = 10, pad = 0),
  automargin.x = TRUE,
  automargin.y = TRUE,
  padding = 0,
  displayModeBar = TRUE,
  modeBar.file.format = "svg",
  filename = NULL,
  file.width = 500,
  file.height = 500,
  file.scale = 1,
  trace = 0,
  ...
)

Arguments

x

vector (possibly named), matrix, or data.frame: If matrix or data.frame, rows are groups (can be 1 row), columns are features

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

horizontal

Logical: If TRUE, plot bars horizontally

theme

Character: Theme to use: Use themes() to get available themes

palette

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

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.

group.names

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

order.by.val

Logical: If TRUE, order bars by increasing value. Only use for single group data. Default = NULL

ylim

Float, vector, length 2: y-axis limits.

hovernames

Character, vector: Optional character vector to show on hover over each bar.

feature.names

Character, vector, length = NCOL(x): Feature names. Default = NULL, which uses colnames(x)

font.size

Float: Font size for all labels. Default = 16

annotate

Logical: If TRUE, annotate stacked bars

annotate.col

Color for annotations

legend

Logical: If TRUE, draw legend. Default = NULL, and will be turned on if there is more than one feature present

legend.col

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

legend.xy

Numeric, vector, length 2: x and y for plotly's legend

legend.orientation

"v" or "h" for vertical or horizontal

legend.xanchor

Character: Legend's x anchor: "left", "center", "right", "auto"

legend.yanchor

Character: Legend's y anchor: "top", "middle", "bottom", "auto"

hline

Float: If defined, draw a horizontal line at this y value.

hline.col

Color for hline. Default = "#ff0000" (red)

hline.width

Float: Width for hline. Default = 1

hline.dash

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

hline.annotate

Character: Text of horizontal line annotation if hline is set

hline.annotation.x

Numeric: x position to place annotation with paper as reference. 0: to the left of the plot area; 1: to the right of the plot area

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

padding

Integer: N pixels to pad plot. Default = 0

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

filename

Character: Path to file to save static plot. Default = NULL

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

trace

Integer: The height the number the more diagnostic info is printed to the console

...

Additional arguments passed to theme

Author(s)

E.D. Gennatas

Examples

## Not run: 
dplot3_bar(VADeaths, legend.xy = c(0, 1))
dplot3_bar(VADeaths, legend.xy = c(1, 1), legend.xanchor = "left")
# simple individual bars
a <- c(4, 7, 2)
dplot3_bar(a)
# if input is a data.frame, each row is a group and each column is a feature
b <- data.frame(x = c(3, 5, 7), y = c(2, 1, 8), z = c(4, 5, 2))
rownames(b) <- c("Jen", "Ben", "Ren")
dplot3_bar(b)
# stacked
dplot3_bar(b, barmode = "stack")

## End(Not run)

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