Learn R Programming

CCAMLRGIS (version 4.2.1)

add_col: 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"))

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.

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.

See Also

add_Cscale, create_PolyGrids, add_Legend, R colors.

Examples

Run this code

# 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)


Run the code above in your browser using DataLab