Learn R Programming

denstrip (version 1.5.4)

denstrip.legend: Add a legend to a density strip or shaded region

Description

Add a legend to an existing plot with a density strip or shaded region, indicating the mapping of colours to densities.

Usage

denstrip.legend(x, y, width, len, colmax, colmin="white", gamma=1,
                horiz=FALSE, max=1, nticks = 5, ticks, value.adj = 0,
                cex, main = "Density", lattice=FALSE)
panel.denstrip.legend(...)

Arguments

x

Central x position of the legend.

y

Central y position of the legend.

width

Width of the legend strip, that is, the length of its shorter dimension. Defaults to 1/30 of the axis range.

len

Length of the legend strip, that is, the length of its longer dimension. Defaults to 1/4 of the axis range.

colmax

Colour at the maximum density, either as a built-in R colour name (one of colors()) or an RGB hex value. Defaults to par("fg") or its lattice equivalent, which is "black" by default.

colmin

Colour to shade the minimum density, likewise. Defaults to "white". If this is set to "transparent", and the current graphics device supports transparency (see rgb), then overlapping strips will merge smoothly.

gamma

Gamma correction to apply to the colour palette, see denstrip.

horiz

Legend strip drawn vertically (FALSE) or horizontally (TRUE).

max

Maximum density on the legend, which is represented by colmax. With the default of 1, the legend indicates the mapping of colours to proportions of the maximum density.

nticks

Number of tick marks on the axis adjacent to the legend, if ticks not supplied.

ticks

Positions of numbered ticks on the axis adjacent to the legend. Defaults to nticks equally spaced ticks between 0 and the maximum density.

value.adj

Extra adjustment for the axis labels to the right (if horiz=FALSE) or downwards (if horiz=TRUE).

cex

Text expansion. Defaults to par("cex") * 0.75 or trellis.par.get("axis.text")$cex * 0.75.

main

Text to place above the legend.

lattice

Set this to TRUE to make denstrip.legend a lattice panel function instead of a base graphics function. panel.denstrip.legend(x,...) is equivalent to denstrip.legend(x, lattice=TRUE, ...).

Other arguments passed to panel.denstrip.legend.

See Also

denstrip, densregion

Examples

Run this code
# NOT RUN {
if (requireNamespace("survival", quietly=TRUE)){

library(survival)
fit <- survfit(Surv(time, status) ~ 1, data=aml, conf.type="log-log")
plot(fit, col=0)
densregion(fit)
denstrip.legend(100, 0.8)

    ### TODO if max not supplied - ticks are not meaningful.
    ### In help example, find actual max dens used for densregion

denstrip.legend(120, 0.8, width=3, len=0.4, value.adj=5)
denstrip.legend(40, 0.9, horiz=TRUE)
denstrip.legend(60, 0.7, horiz=TRUE, width=0.02, len=50, value.adj=0.04)
# }
# NOT RUN {
}



# }

Run the code above in your browser using DataLab