I am trying to get a simple bar plot where my data has both positive and negative numbers. Want to make the colours different for positive and negative bars.
data <- c(-0.52, 0.25, 0.07, -0.44, 0.04, -0.16, -0.45, -1.44, -0.12, -0.17, -0.54, -0.04, -0.47, -0.40, 0.03, -0.78, -0.35 -0.52, 0.25, -0.69, 0.08, 1.11)
barplot(data, col=c("blue","black"))
I tried using a vector for the color
barplot(data,col=c("blue", "blue", "black", "blue", "black", "blue", "blue", "blue",
"blue", "blue", "blue", "blue", "blue", "blue", "black", "blue",
"blue", "blue", "black", "blue", "black", "blue"))
But it takes only the first color. Is it possible to get it in base graphics without ggplot? Thanks for any reply