There are similar question answered here, but not for my particular issue.
Let's have a data frame and ggplot bar:
d <- data.frame(
letters = LETTERS[1:10],
numbers = 11:20
)
ggplot(d, aes(x = letters, y = numbers, fill = letters)) +
geom_bar(stat = "identity")
I need to show only A and J items in legend. I can use this code, but the gradient palette is broken completely and I don't know how to put it back.
ggplot(d, aes(x = letters, y = numbers, fill = letters)) +
geom_bar(stat = "identity") +
scale_fill_manual(breaks = c("A", "J"), values = d$letters)
Do you know it please?
Similiar questions: