Sorted Bar Plots

Share:

Description

Creates a sorted bar plot with vertical or horizontal bars.

Usage

1
2
3
4
5
6
7
barplot_s(height, 
	horiz = FALSE,
	sort_by, 
	decreasing = TRUE, 
	lowtrim, hightrim, trimlegend = TRUE, 
	col, coli, colfun, 
	main, ...)

Arguments

height

either a vector or matrix of values describing the bars which make up the plot. See barplot.

horiz

boolean. Arrange bars horizontally.

sort_by

a variable to sort by. Defaults to height.

decreasing

boolean. Sorting direction.

lowtrim

A optional lower trim value. Observations with sort_by values up to lowtrim are discarded.

hightrim

A optional upper trim value. Observations with sort_by values from lowtrim are discarded.

trimlegend

Boolean. Show a legend about trimmed values.

col

a vector of colors for the bars or bar components. By default, grey is used if height is a vector, and a gamma-corrected grey palette if height is a matrix.

coli

An index into the col table, based on original sorting. If no index is given, the colour will be allocated after sorting.

colfun

A function or function name to generate a col palette. "grey" or "gray" is rescaled to 1..n.

main

overall title for the plot

...

Passed to barplot

Details

If no names are supplied, they are generated in the form x...

You man want to adjust the scale of the bar labels by using an additional argument such as cex.names =0.5.

More to come. Plots are among others from this collection:

Value

Invisible: A data frame with components

x

height

perm

the permutation applied

coli

the colour index applied

col

optional: the colours selected

Note

Part of this could go to the R base function barplot.

Author(s)

G√ľnther Sawitzki <gsawitzki@users.r-forge.r-project.org>

See Also

barplot

Examples

1
2
3
4
5
6
7
8
9
x <- runif(100)

barplot_s(x)

x <- rnorm(100)

barplot_s(x, colfun=heat.colors, lowtrim=-1)

rm(x)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.