library(tidyverse)
delta <- tibble(
type = c("alpha", "beta", "gamma"),
a = rnorm(3, 5),
b = rnorm(3, 6)
) %>%
mutate(delta = abs(a - b)) %>%
gather(`a`, `b`, `delta`, key = "letter", value = "value")
ggplot(delta %>% filter(letter != "delta"), aes(type, value, fill = letter)) +
geom_col(position = "dodge") +
geom_col(data = delta %>% filter(letter == "delta"), width = 0.5) +
scale_color_manual("grey", "black", "blue")
I'd like the a and b bars to be grey and black. And the delta bar to be blue. How do I do this with scale_color_manual()? Seems my syntax above is off.

There are two things that need to be changed:
Since you've used fill = letter, you should use scale_fill_manual instead of scale_color_manual (which would have been appropriate if you had used color = letter).
The manual color values should be provided as a vector.
library(tidyverse)
delta <- tibble(
type = c("alpha", "beta", "gamma"),
a = rnorm(3, 5),
b = rnorm(3, 6)
) %>%
mutate(delta = abs(a - b)) %>%
gather(`a`, `b`, `delta`, key = "letter", value = "value")
ggplot(delta %>% filter(letter != "delta"), aes(type, value, fill = letter)) +
geom_col(position = "dodge") +
geom_col(data = delta %>% filter(letter == "delta"), width = 0.5) +
scale_fill_manual(values = c("grey", "black", "blue"))

Created on 2018-10-08 by the reprex package (v0.2.1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With