Learn R Programming

metools (version 1.0.0)

p.colorbypositive: Color by positive or negative

Description

p.colorbypositive is a function to create a vector with colors by positive or negative. Recommended to color graphics created with metools p.functions.

Usage

p.colorbypositive(x, colorp = "#17B221", colorn = "#B21717")

Arguments

x

a numeric vector

colorp

Positive values color (default=Green)

colorn

Negative values color (default=Red)

Value

Return a vector with colors.

Examples

Run this code
# NOT RUN {
v=c(-3,-2,2,-2,3,2)
p.colorbypositive(x=v,colorp="blue",colorn="grey")

barplot(v,col=p.colorbypositive(v))

# }

Run the code above in your browser using DataLab