There's more than one way to do this, but here's one approach:
library(tidyverse)
bar_data <- mtcars %>%
group_by(cyl) %>%
summarize(hp_mean = mean(hp)) %>%
mutate(hilite = hp_mean > quantile(hp_mean, 0.75))
ggplot(bar_data) +
geom_col(aes(
x = factor(cyl),
y = hp_mean,
fill = hilite
)) +
scale_fill_manual(name = "Performance",
values = c("TRUE" = "red", "FALSE" = "grey50"),
labels = c("TRUE" = "Double-plus good", "FALSE" = "Just OK")
)
