In geom_* functions, the show.legend parameter can be either TRUE or FALSE and applies to the whole layer.
When TRUE (the default), lines appear in the legends for factor(vs) (colour) and factor(am) (linetype):
library(ggplot2)
ggplot(mtcars) +
geom_point(aes(mpg, qsec, colour = factor(vs), shape = factor(am))) +
geom_line(aes(mpg, qsec, colour = factor(vs), linetype = factor(am)))

When FALSE, lines do not appear in the legend at all:
ggplot(mtcars) +
geom_point(aes(mpg, qsec, colour = factor(vs), shape = factor(am))) +
geom_line(aes(mpg, qsec, colour = factor(vs), linetype = factor(am)), show.legend = FALSE)

The idea would be to provide a named logical vector to show.legend in order to specify which aesthetic are shown in the legend for this layer, like so, where lines appear in the legend for factor(am) but not for factor(vs):
ggplot(mtcars) +
geom_point(aes(mpg, qsec, colour = factor(vs), shape = factor(am))) +
geom_line(aes(mpg, qsec, colour = factor(vs), linetype = factor(am)),
show.legend = c(colour = FALSE))

Please let me know if you think this could be a useful addition. I tried my hand at implementing this (see here) and this works (except when using color instead of colour) but I'm sure there is a better way if you decide to implement it.
In
geom_*functions, theshow.legendparameter can be either TRUE or FALSE and applies to the whole layer.When TRUE (the default), lines appear in the legends for
factor(vs)(colour) andfactor(am)(linetype):When FALSE, lines do not appear in the legend at all:
The idea would be to provide a named logical vector to
show.legendin order to specify which aesthetic are shown in the legend for this layer, like so, where lines appear in the legend forfactor(am)but not forfactor(vs):Please let me know if you think this could be a useful addition. I tried my hand at implementing this (see here) and this works (except when using
colorinstead ofcolour) but I'm sure there is a better way if you decide to implement it.