Reputation: 788
I have a simple (maybe) question on ggplot2.
I would like to drop one of the variables in the legend, lets say trt1
in the example below.
How do I do that? I would still like for it to be plotted just the variable should be removed from the legend.
Thanks for all your help!
Below is a simple example:
library(ggplot2)
bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot()
bp
Upvotes: 1
Views: 83
Reputation: 37879
Use this. scale_fill_discrete
is what you need:
library(ggplot2)
bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() +
scale_fill_discrete(breaks=c("ctrl","trt2"))
bp
Upvotes: 1