library(ggplot2)
# Plot with multiple legends
p <- ggplot(mtcars, aes(mpg, wt, color = factor(cyl), size = hp,
shape = factor(am))) +
geom_point()
# Keep only the colour legend
p + legend_select(colour)
# Keep colour and shape, hide size
p + legend_select(colour, shape)
Run the code above in your browser using DataLab