Skip to contents

For "mid.breakdown" objects, plot() visualizes the breakdown of a prediction by component functions.

Usage

# S3 method for class 'mid.breakdown'
plot(
  x,
  type = c("waterfall", "barplot", "dotchart"),
  theme = NULL,
  terms = NULL,
  max.bars = 15L,
  width = NULL,
  vline = TRUE,
  catchall = "others",
  format = c("%t=%v", "%t"),
  ...
)

Arguments

x

a "mid.breakdown" object to be visualized.

type

a character string specifying the type of the plot. One of "barplot" or "dotchart".

theme

a character string specifying the color theme or any item that can be used to define "color.theme" object.

terms

an optional character vector specifying the terms to be displayed.

max.bars

an integer specifying the maximum number of bars in the barplot, boxplot and dotchart.

width

a numeric value specifying the width of the bars.

vline

logical. If TRUE, the vertical line is drawn at zero or the intercept.

catchall

a character string to be used as the catchall label.

format

a character string or character vector of length two to be used as the format of the axis labels. "t" and "v" immediately after the percent sign are replaced with the corresponding term and value.

...

optional parameters to be passed to the graphing function. Possible arguments are "col", "fill", "pch", "cex", "lty", "lwd" and aliases of them.

Value

plot.mid.breakdown() produces a plot and returns NULL.

Details

The S3 method of plot() for "mid.breakdown" objects creates a visualization of the MID breakdown using the functions of the graphics package.

Examples

data(diamonds, package = "ggplot2")
set.seed(42)
idx <- sample(nrow(diamonds), 1e4)
mid <- interpret(price ~ (carat + cut + color + clarity)^2, diamonds[idx, ])
#> 'model' not passed: response variable in 'data' is used
mbd <- mid.breakdown(mid, diamonds[1L, ])
plot(mbd, type = "waterfall")

plot(mbd, type = "waterfall", theme = "midr")

plot(mbd, type = "barplot", theme = "Set 1")

plot(mbd, type = "dotchart", theme = "Cividis")