add_col: Add colors

View source: R/add_col.R

add_colR Documentation

Add colors

Description

Given an input variable, generates either a continuous color gradient or color classes. To be used in conjunction with add_Cscale.

Usage

add_col(var, cuts = 100, cols = c("green", "yellow", "red"))

Arguments

var

numeric vector of the variable to be colorized. Either all values (in which case all values will be assigned to a color) or only two values (in which case these are considered to be the range of values).

cuts

numeric, controls color classes. Either one value (in which case n=cuts equally spaced color classes are generated) or a vector (in which case irregular color classes are generated e.g.: c(-10,0,100,2000)).

cols

character vector of colors (see R standard color names here). cols are interpolated along cuts. Color codes as those generated, for example, by rgb may also be used.

Value

list containing the colors for the variable var (given as $varcol in the output) as well as the single cols and cuts, to be used as inputs in add_Cscale.

See Also

add_Cscale, create_PolyGrids, R colors.

Examples


# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#52-adding-colors-to-data

MyPoints=create_Points(PointData)
MyCols=add_col(MyPoints$Nfishes)
plot(st_geometry(MyPoints),pch=21,bg=MyCols$varcol,cex=2)



CCAMLRGIS documentation built on Sept. 27, 2023, 9:09 a.m.