Skip to contents

Displays a compositional bar chart.

Usage

# S4 method for class 'CompositionMatrix'
barplot(
  height,
  ...,
  order_columns = FALSE,
  order_rows = NULL,
  decreasing = TRUE,
  space = 0.2,
  offset = 0.025,
  palette_color = palette_color_discrete(),
  border = NA,
  axes = TRUE,
  legend = TRUE
)

Arguments

height

A CompositionMatrix object.

...

Further graphical parameters.

order_columns

A logical scalar: should should columns be reorderd?

order_rows

An integer vector giving the index of the column to be used for the ordering of the data.

decreasing

A logical scalar: should the sort order of rows be increasing or decreasing?

space

A length-one numeric vector giving the the amount of space (as a fraction of the width of a bar) left between each bar (defaults to \(0.2\)).

offset

A length-one numeric vector giving the the amount of space (as a fraction) left between groups (defaults to \(0.025\)). Only used if groups is not NULL.

palette_color

A palette function that when called with a single argument returns a character vector of colors.

border

The color to draw the borders.

axes

A logical scalar: should axes be drawn on the plot?

legend

A logical scalar: should the legend be displayed?

Value

barplot() is called for its side-effects: is results in a graphic being displayed (invisibly return height).

See also

Other plot methods: as_graph(), hist(), pairs(), plot()

Author

N. Frerebeau

Examples

## Data from Aitchison 1986
data("hongite")

## Coerce to compositional data
coda <- as_composition(hongite)

## Bar plot
barplot(coda)


## Data from Day et al. 2011
data("kommos", package = "folio")
kommos <- remove_NA(kommos, margin = 1) # Remove cases with missing values
coda <- as_composition(kommos, groups = 1) # Coerce to compositional data

## Use ceramic types for grouping
barplot(coda, order_columns = TRUE)


## Display only minor elements
minor <- coda[, is_element_minor(coda)]
barplot(minor, order_columns = TRUE)