Dear R- Experts,

I hope that you are doing well.

I am facing a problem with adding color to a barplot. My target is to add a
bar color conditioning on the following

Values close to 1 represent "White" and values tend to 0 represent "Black".

However, I failed. The code is given below. I will be happy and thankful if
anyone helps me in this regard.

Thanks in advance.

library(ggplot2)
predictors=c("x1", "x2", "x3", "x4", "x5")
values=c(1.0, 0.67, 0.26, 0.18, 0.17)
prob=c(1.0, 0.001, 0.957, 0.924, 0.253)

df <- data.frame(predictors, values, prob)
ggplot(df, aes(x=predictors, y=values) ) +
  geom_bar(stat="identity") +
  coord_flip()+
  scale_fill_manual(values=c("gray(prob)"))

Best Regards,

*Hossain*

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to