bars: Plotting Bars

View source: R/bars.R

barsR Documentation

Plotting Bars

Description

Plotting function alternative to barplot().

This function is using polygon() to plot bars in an existing plot device. Note that this function is working as a low level plotting function, thus at least an empty plot should be drawn in advance.

Usage

br(x, x0 = 0, at, maxwidth = 0.5, vertical = TRUE, ...)

bars(x, ...)

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

## S3 method for class 'numeric'
bars(x, x0 = 0, at, maxwidth = 0.5, vertical = TRUE, ...)

Arguments

x

Numeric vector with the height of bars.

x0

Numeric vector with the values for the bottom of the bars.

at

Numeric vector with the position of bars.

maxwidth

Width of bars in plot units.

vertical

Logical value indicating whether the bars should be drawn vertically (TRUE, the default) or horizontally (FALSE).

...

Further arguments passed to polygon().

Author(s)

Miguel Alvarez (kamapu78@gmail.com).

Examples

data(iris)

## Mean value of petal length by species
iris <- aggregate(Petal.Length ~ Species, iris, mean)

## Plotting steps
plot(NA,
  xlim = c(0.5, 3.5), ylim = c(0, max(iris$Petal.Length)), xaxt = "n",
  xlab = "Species", ylab = "petal length (cm)", type = "n"
)
axis(side = 1, at = c(1:3), labels = iris$Species)
bars(iris$Petal.Length, at = 1, col = "grey")


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