magbar: Pretty colour bar

View source: R/magbar.R

magbarR Documentation

Pretty colour bar

Description

This function is a high level interface to the plotrix 'color.legend' function. It makes reasonable assumptions on the plottin window to place the colour and allows the user to specify log spacing for the colour gradient and labels, as well as add a title.

Usage

magbar(position = "topright", range = c(0, 1), orient = "v", log = FALSE,
  col = hcl.colors(21), scale = c(1/4, 1/20), inset = 1/40, labN = 5, title = "",
  titleshift = 0, centrealign = "rb", clip = '', cex=1, ...)

Arguments

position

Relative position of the colour bar. This argument is used like the 'legend' function. Specify one of 'bottom', 'bottomleft', 'left', 'topleft', 'top', 'topright', 'right', 'bottomright' and 'centre'.

range

The text label limits used to label the colour bar.

orient

Orientation. Allowed options are 'v' for vertical and 'h' for horizontal.

log

Should the colour spacing and labelling be log spaced.

col

Colour palette to use for the colouring of the bar.

scale

The relative (to the plot window) length and width of the colour bar.

inset

Relative (to the plot window) inset of the colour bar.

labN

The number of text labels to draw on the colour bar.

title

Optional title (or axis label for the labels) to add to the colour bar.

titleshift

Extra shift to apply to the 'title' position.

centrealign

Option to control the labeling position used when the position='centre'.

clip

Setting clip='bg' will set values outside the 'range' values to be blank on the magbar (i.e. you can see through to the background).

cex

Character expansion factor for the labels.

...

Other arguments to pass to the color.legend function.

Details

This function creates pretty default colour bars by assessing the current plot window. It is a higher level implementation of the plotrix 'color.legend' function.

Value

Called for the side effect of plotting a colour bar.

Author(s)

Aaron Robotham

See Also

magplot, magaxis, maglab, magmap, magrun

Examples

magplot(sin)
magbar('top')
magbar('right',title='Just looking',titleshift=0.5)
magbar('topleft',orient='h',title='Hello!')
magbar('bottom',range=c(0.3,30),orient='h',log=TRUE,title='Log test col')
magbar('bottomleft',range=c(0.3,30),orient='v',log=TRUE,title='Log test bg',clip='bg')


asgr/magicaxis documentation built on May 14, 2022, 11:14 p.m.