The last geom_line
is the only geom here that is mapped to y = share2. You could either replace the last line with:
plot1 +
geom_point(aes(y = share2)) +
geom_line(aes(y = share2), color = "blue")
or, more idiomatically, you could convert your data to long (aka "tidy") format before you send it into ggplot. Something like the code below will combine your two columns that you want to plot (share1 and share2) into one column, distinguished by a new column called share_type
.
table3 %>%
gather(share_type, value, share1:share2)
Then you'd map that field in your ggplot call, something like this, and it would plot both of your series, and add a legend.
plot1 <- ggplot(table3, aes(x = issue_yr, y = value, color = share_type)) +
geom_line() + # Color of the line will be mapped based on share_type
geom_point(color = "black") # Assumes you want all points black
I think ggplot is quite elegant when you can use its built-in mapping to do the work for you. If you want to manually control the appearance of your various series, you can use scale_color_manual() to pick the colors you want to use.