To remove the legend for a particular aesthetic, add the following functions to your plot:
guides( fill = FALSE) #To remove legend for fill aesthetic
guides( color = FALSE) #To remove legend for color aesthetic
guides( shape = FALSE) #To remove legend for shape aesthetic
theme(legend.position = “none”) #To remove all legends
For example:
Plot with all legends:
library("ggplot2")
ggplot(data = mtcars, aes(x = mpg, y = disp, group = gear)) + geom_point(aes(color = vs)) + geom_point(aes(shape = factor(cyl))) + geom_line(aes(linetype = factor(gear))) + geom_smooth(aes(fill = factor(gear), color = gear)) + theme_bw()
Plot without the shape legend:
ggplot(data = mtcars, aes(x = mpg, y = disp, group = gear)) + geom_point(aes(color = vs)) + geom_point(aes(shape = factor(cyl))) + geom_line(aes(linetype = factor(gear))) + geom_smooth(aes(fill = factor(gear), color = gear)) + theme_bw() + guides(shape = FALSE)
Plot without any legend:
ggplot(data = mtcars, aes(x = mpg, y = disp, group = gear)) +
geom_point(aes(color = vs)) +
geom_point(aes(shape = factor(cyl))) +
geom_line(aes(linetype = factor(gear))) +
geom_smooth(aes(fill = factor(gear), color = gear)) +
theme_bw() +
theme(legend.position = "none")