Learn R Programming

sptemExp (version 0.1.4)

colorGrinf: Generation of Customed Gradient Colors

Description

This function is to generate the color gradient with the customed levels

Usage

colorGrinf(x, levels=NA, colors=c("green","yellow","red"), colsteps=10)

Arguments

x

A vector value

levels

levels of gradient colors

colors

Color ranges

colsteps

Levels of color gradient.

Value

levels

Level of values for legend use

cols

Color ranges for legeng use

index

Color values for map.

Examples

Run this code
# NOT RUN {
#Example

x=sample(c(1:1000),size=100)
x=x[order(x)]
ret=colorGrinf(x)

# }
# NOT RUN {
# A block Kriging example :

data("spointspre","countylayer")
tarF="d91" # target variable to be kriged
regionName="NAME_3"
bkRes=sptemExp::getTidBKMean(spointspre,countylayer,regionName,tarF,2)

bkRes=bkRes[!is.na(bkRes$bkm_fill),]
levels=c(30,60,100,150,250)
cr=sptemExp::colorGrinf(bkRes$bkm_fill,levels,colors=c("darkgreen","yellow","darkred"))
par(mar=c(1,1,1,1))
title=expression("Regional Block Kriged PM"[2.5]*" Concentration Estimated")
raster::plot(bkRes,col =cr$cols[cr$index],main=title)
legend("bottomright", fill =cr$cols, legend = cr$levels,col =cr$cols, cex=1,bty="n",bg="n")

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab