insetScale: Add an inset color scale to a plot

insetScaleR Documentation

Add an inset color scale to a plot

Description

Adds an inset color scale to a plot without disrupting future plotting. Especially useful with heatmap or image plots.

Usage

insetScale(
  breaks,
  col,
  insetPos = c(0.025, 0.015, 0.04, 0.25),
  main = "",
  offset = 0.001,
  at = NULL,
  labels = NULL,
  cex = 1,
  labXOffset = 0,
  labYOffset = 0
)

Arguments

breaks

a set of finite numeric breakpoints for the colours: must have one more breakpoint than colour and be in increasing order.

col

a list of colors such as that generated by 'rainbow', 'heat.colors', 'topo.colors', 'terrain.colors' or similar functions.

insetPos

a four element numeric vector giving the position of the bottom, left, top and right edges of the scale in nfc coordinates (0 = bottom/left of figure, 1 = top/right of figure)

main

a character string giving label for color scale

offset

add a small offset to rectangles to suppress pdf viewers showing a gap at exact border between rectangles

at

positions for labels on the axis

labels

labels for the axis

cex

character size for axis and labels

labXOffset

a vector of the same length as labels to be used to fine tune label positioning. Values given proportional to plot size

labYOffset

a vector of the same length as labels to be used to fine tune label positioning. Values given proportional to plot size

See Also

heatmap, image

Examples

dists<-as.matrix(dist(sort(runif(40))))
breaks<-seq(0,1,.01)
cols<-rev(heat.colors(length(breaks)-1))
heatmap(dists,col=cols)
insetScale(breaks,cols,main='Distance')

sherrillmix/dnar documentation built on July 18, 2022, 10:07 p.m.