shadowplot: Shadowplots for categorical variables

View source: R/shadowplot.R

shadowplotR Documentation

Shadowplots for categorical variables

Description

Plot single 'shadow'. This function is called by shadowplot() and works only as a low-level plot function.

The function shadow() calculates the frequency of single values in the vector x and displays them as a shadow using the function polygon(). The resulting shadow indicates by its with the relative frequency of the respective values in the input vector. If not provided, the values of start and end will be calculated by min() and max(), respectively. This plot function is offered as an alternative to boxplot() for categorical and ordinal data and should be interpreted as an histogram.

The function shadowplot() produces a plot of frequencies for classes of categorical variables and is similar to box-and-whisker plots boxplot()) but also to histograms hist()).

This plot function is offered as an alternative to boxplot() for categorical and ordinal data and single shadows should be interpreted as histograms. To plot single shadows the function shadows() is called internally. Alternatively stringplot() or a combination of both can be used.

Usage

shadows(x, start, end, at, maxwidth = 1, col = "grey", border = NA, ...)

shadowplot(x, ...)

## Default S3 method:
shadowplot(x, ...)

## S3 method for class 'numeric'
shadowplot(
  x,
  start,
  end,
  at,
  maxwidth = 1,
  col = "grey",
  border = NA,
  bty = "n",
  xaxt = "n",
  ylim,
  xlab = "",
  ylab = "classes",
  ...
)

## S3 method for class 'data.frame'
shadowplot(
  x = data.frame(),
  what,
  by,
  start,
  end,
  at,
  maxwidth = 1,
  col = "grey",
  border = NA,
  xlab = "",
  ylab = "classes",
  xlim,
  ylim,
  xaxt = "s",
  ...
)

## S3 method for class 'formula'
shadowplot(formula, data = data.frame(), ...)

Arguments

x

Either an integer vector or a data frame.

start

Lowest possible value for the variable 'x' as integer.

end

Highest possible value for the variable 'x' as integer.

at

Position of the shadow in the x-axis of the plot.

maxwidth

Magnification factor for the maximum width of shadow.

col

Color of the shadow (passed to polygon()).

border

Color of the shadow's border (passed to polygon()).

...

Further arguments to be passed among methods.

bty

Type of box around plotting area (see par()).

xaxt

Specification of x axis type (see par()).

xlab

Labels for x axis (see par()).

ylab

Labels for y axis (see par()).

what

Name of the variable to be plotted (in data frame method).

by

Name of the splitting variable (in data frame method).

xlim, ylim

Limits for x and y axes (see par()).

formula

A formula for plotting.

data

Data frame containing the vectors to be plotted.

Author(s)

Miguel Alvarez (malvarez@uni-bonn.de).

Examples

## Similar example as for strp
data(WHscores)

## Shadow overlaid to box and whisker plot using transparent color
## (note the bimodal distribution)
boxplot(WHscores$WET_veg, col = "grey")
shadows(WHscores$WET_veg,
  col = rgb(153 / 255, 255 / 255, 153 / 255, alpha = 0.5),
  at = 1
)

## Plot using formula
shadowplot(WET_veg ~ Landuse, WHscores,
  start = 0, end = 10,
  col = c("orangered", "palegreen", "orange", "lightblue")
)

## Adding a stringplot
stringplot(WET_veg ~ Landuse, WHscores, lwd = 3, at = 1)


kamapu/Lexiguel documentation built on July 29, 2022, 7:52 p.m.