Colour Strip Legend

Description

This function is used with shaded plots to display a legend.

Usage

1
2
3
strip.legend(xy, legend, col, legendtype = c("breaks", "intervals", "other"),
  tileborder = NA, height = 0.5, width = 0.06, inset = 0.06, text.offset = 0.02,
  text.cex = 0.9, xpd = TRUE, scale = 1, title = "", box = NA, box.col = par()$bg)

Arguments

xy

location of legend (see Details)

legend

character vector (see Details)

col

vector of colour values

legendtype

character

tileborder

colour of lines around each tile in the colour strip. Use NA for none.

height

height of colour strip as a fraction of the plot dimensions

width

width of colour strip as a fraction of the plot dimensions

inset

spacing between legend and outside plot boundary, as a fraction of the plot dimensions

text.offset

spacing between colour strip and text, as a fraction of the plot dimensions

text.cex

size of text font

xpd

logical, if TRUE the legend will use the margins of the plot

scale

numeric; each value x will be displayed as scale * x

title

text displayed above legend

box

colour of frame, if framed, otherwise NA

box.col

colour of background, if framed, otherwise ignored

Details

The location of the legend is determined by xy which may be one of the character values "topright", "topleft", "bottomright", "bottomleft", "right", "left", or the x-y coordinates (in user units) of the top-left corner of the colour strip. Coordinates may be given as a vector or a list, and the output from locator(1) is suitable.

For more on colours, see notes in plot.mask and colors and terrain.colors

If legendtype = 'breaks' then labels are placed at the class boundaries; otherwise, the labels are centred vertically. If legendtype = 'breaks' or legendtype = 'intervals' then numeric values are extracted from the input, otherwise the text strings in legend are used as provided.

The legend itself may be provided as a vector of values or as the class labels output from plot.mask. Class labels are generated by cut in the form ‘(0,20]’, ‘(20,40]’, etc. These are parsed to construct either breaks (0,20,40,...) or intervals (‘0-20’, ‘20-40’,...) as requested in the legendtype argument.

box may also be TRUE/FALSE; if TRUE the foreground colour is used par()$fg.

Value

Invisibly returns a vector of user coordinates for the left, right, bottom and top of the colour strip.

Note

From secr 2.9.0, the default behaviour of plot.mask is to call strip.legend to display a legend in the top right of the plot, labeled at breaks.

See Also

plot.mask

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
temptrap <- make.grid()
tempmask <- make.mask(temptrap)
covariates (tempmask) <- data.frame(circle = 
    exp(-(tempmask$x^2 + tempmask$y^2)/10000) )
tmpleg <- plot (tempmask, covariate = "circle", dots = FALSE, 
    breaks = 10, legend = FALSE)
strip.legend (xy = 'topright', col = terrain.colors(10),
    legend = tmpleg, title = "Test plot")

## Not run: 
## a custom axis using the returned values
par(mar = c(2,2,2,6))
plot (tempmask, covariate = "circle", dots = FALSE, 
    breaks = 10, legend = FALSE)
b <- strip.legend (locator(1), col = terrain.colors(10),
    legendtype = "other", legend = "    ", title = "Test plot",
     height = 0.3, box = NA)
axis(side = 4, pos = b[2]+5, at = seq(b[4], b[3], length = 3),
    lab = seq(0,1,0.5), las = 1, tck = -0.02)
par(mar = c(5,4,4,2) + 0.1)  ## reset to default


## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.