powered by
p.colorbypositive is a function to create a vector with colors by positive or negative. Recommended to color graphics created with metools p.functions.
p.colorbypositive(x, colorp = "#17B221", colorn = "#B21717")
a numeric vector
Positive values color (default=Green)
Negative values color (default=Red)
Return a vector with colors.
# 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