caxis: Add a color axis

View source: R/plot_extra.R

caxisR Documentation

Add a color axis

Description

Add a color-coded axis.

Usage

caxis(side, prop, col = NULL, lwd = 3, ...)

Arguments

side

an integer specifying which side of the plot the axis is to be drawn on: 1=below, 2=left, 3=above, and 4=right

prop

the proportion of each section to be scaled to the axis width

col

a vector of colors equal to the length of prop

lwd

line width for the axis

...

additional parameters passed to segments

Value

A list containing the start and end positions for each prop scaled to the axis width.

Examples

x <- runif(100)
y <- runif(100)

plot(x, y)
caxis(1, 1:4, col = 2:5)
at <- caxis(3, 1:4, col = 2:5)
text(at$end, par('usr')[4], paste('group', 1:4),
     col = 2:5, xpd = NA, adj = c(1, -1))


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.