I have tried adding linetype to the aes but it does not change anything....This shouldn't be this hard but I'm at a loss.
Sometimes the overabundance of specialized functions combined with the aes-legend linkage can make custom legends more difficult than in base R graphics. But this seems like a pretty typical use case and you're right that putting linetype
in aes()
is the way to solve this. Your precip
dataset isn't the R precip
data, so here's a simple example that seems to do what you want
ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_line(aes(linetype = factor(am, levels = c(0,1), labels = c("Manual", "Automatic")))) +
scale_linetype_manual(values = c("twodash", "solid"), name = "Transmission") +
geom_point(size = 2) +
labs(x= "Weight (Tons)", y= "MPG") +
theme_classic()