drawColorBar: Draw a color bar into the right plot margin

Description Usage Arguments Value Author(s) Examples

View source: R/drawColorBar.R

Description

Image plots usually codify the z values with colors. This function helps to draw an appropriate color bar into the right plot margin.

Usage

1
2
3
4
5
drawColorBar(breaks = NULL, col = NULL, usr = par("usr"),
             xleft = 0.05, xright = 0.08,
             ybottom = 0.25, ytop = 0.25,
             main = "z", main.cex = 1.5, main.mar = 0.01,
             lab.cex = 1, lwd = 0.5, seg.len = 0.2)

Arguments

breaks

numeric vector. The breaks that are used to bin the numerical range. Should be of length(col)+1.

col

vector. Defines for each bin a color.

usr

numeric vector. Defines the plotting region in user coordinates according to c(x_min,x_max,y_min,y_max).

xleft

real number. Sets the left coordinate as a fraction of the width defined by usr[1:2].

xright

real number. Sets the right coordinate as a fraction of the width defined by usr[1:2].

ybottom

real number. Sets the bottom coordinate as a fraction of the height defined by usr[3:4].

ytop

real number. Sets the top coordinate as a fraction of the height defined by usr[3:4].

main

string. Optional title for the color bar.

main.cex

real number. Character size expansion for main, which is passed to text.

main.mar

real number. Sets the margin of the title relativ to the color bar as a fraction of the height defined by usr[3:4].

lab.cex

real number. Character size expansion for the bar labels, which is passed to text.

lwd

real number. Line width to draw the tick marks and box around the color bar.

seg.len

real number. Length of the tick marks as a fraction of xright-left.

Value

Returns invisible.

Author(s)

Simon S.

Examples

1
2
3
4
5
6
breaks <- 1:50
col <- rainbow(49)
z <- matrix(runif(n=100,min=1.1,max=49.9),nrow=10,ncol=10)
par(mar=c(4,5,3,6))
image(z=z,col=col,breaks=breaks)
drawColorBar(breaks=breaks,col=col,main='bar')

hydro-giub/hydroBE documentation built on Sept. 20, 2019, 9:27 a.m.