draw_varimp: Interactive Variable Importance Plot

View source: R/draw_varimp.R

draw_varimpR Documentation

Interactive Variable Importance Plot

Description

Plot variable importance using plotly

Usage

draw_varimp(
  x,
  names = NULL,
  main = NULL,
  type = c("bar", "line"),
  xlab = NULL,
  ylab = NULL,
  plot_top = 1,
  orientation = "v",
  line_width = 12,
  labelify = TRUE,
  col = NULL,
  alpha = 1,
  palette = rtemis_palette,
  mar = NULL,
  font_size = 16,
  axis_font_size = 14,
  theme = choose_theme(),
  showlegend = TRUE,
  filename = NULL,
  file_width = 500,
  file_height = 500,
  file_scale = 1
)

Arguments

x

Numeric vector: Input.

names

Vector, string: Names of features.

main

Character: Main title.

type

Character: "bar" or "line".

xlab

Character: x-axis label.

ylab

Character: y-axis label.

plot_top

Integer: Plot this many top features.

orientation

Character: "h" or "v".

line_width

Numeric: Line width.

labelify

Logical: If TRUE, labelify feature names.

col

Vector, colors: Single value, or multiple values to define bar (feature) color(s).

alpha

Numeric: Transparency.

palette

Character: Name of rtemis palette to use.

mar

Vector, numeric, length 4: Plot margins in pixels (NOT inches).

font_size

Integer: Overall font size to use (essentially for the title at this point).

axis_font_size

Integer: Font size to use for axis labels and tick labels.

theme

Theme object.

showlegend

Logical: If TRUE, show legend.

filename

Character: Path to save the plot image.

file_width

Numeric: Width of the saved plot image.

file_height

Numeric: Height of the saved plot image.

file_scale

Numeric: Scale of the saved plot image.

Details

A simple plotly wrapper to plot horizontal barplots, sorted by value, which can be used to visualize variable importance, model coefficients, etc.

Value

plotly object.

Author(s)

EDG

Examples

## Not run: 
# made-up data
x <- rnorm(10)
names(x) <- paste0("Feature_", seq(x))
draw_varimp(x)
draw_varimp(x, orientation = "v")

## End(Not run)

egenn/rtemis documentation built on June 14, 2025, 11:54 p.m.