I am trying to change color to specific variable in stacked bar chart
in ggplot
.
I've found this link, but it is not what I want. R ggplot Changing color of one variable in stacked bar graph
I want to change Brand7
color to black, but the rest of brands should be colored in different random colors.
What I want, is to use some kind of conditional to select color for one specific brand, the other brands could be as it was before.
Also I enclose reproducable example.
set.seed(1992)
n=8
Category <- sample(c("Car", "Bus", "Bike"), n, replace = TRUE, prob = NULL)
Brand <- sample("Brand", n, replace = TRUE, prob = NULL)
Brand <- paste0(Brand, sample(1:14, n, replace = TRUE, prob = NULL))
USD <- abs(rnorm(n))*100
df <- data.frame(Category, Brand, USD)
ggplot(df, aes(x=Category, y=USD, fill=Brand)) +
geom_bar(stat='identity')