p.colorbyvar {metools} | R Documentation |
p.colorbyvar is a function to create a vector with colors by variation. Recommended to color graphics created with metools p.functions.
p.colorbyvar(x, colorp = "#17B221", colorn = "#B21717", lag = 1)
x |
a numeric vector |
colorp |
Positive changes color (default=Green) |
colorn |
Negative changes color (default=Red) |
lag |
Lag to comparison (default=1) |
Return a vector with colors.
v=c(3,2,5,6,5,4)
p.colorbyvar(x=v,colorp="blue",colorn="grey")
barplot(v,col=p.colorbyvar(v))