0

I have plotted a second set of lines with different point shapes and line types to denote another characteristic for two countries across a period. However, the appears that the new symbology has been displayed on top of the existing legend. How can I separate them out, so that I have two legends: one with line 1+symbol 1 for the first data type and line 2+symbol 2

mtcars2 <- mtcars
mtcars2$gear <- as.character(mtcars2$gear)
mtcars2 %>% 
  ggplot()+
  geom_point(aes(x = disp, y = drat, color = gear))+
  geom_line(aes(x = disp, y = drat, color = gear))+
  geom_point(aes(x = disp, y = qsec, color = gear), shape = 17)+
  geom_line(aes(x = disp, y = qsec, color = gear), linetype = "dashed")
  • 3
    Could you please share some reproducible data using `dput`? – Quinten Jul 26 '22 at 13:19
  • 3
    Welcome to SO, overfieldc! Questions on SO (especially in R) do much better if they are reproducible and self-contained. By that I mean including sample representative data (perhaps via `dput(head(x))` or building data programmatically (e.g., `data.frame(...)`), possibly stochastically), perhaps actual output (with verbatim errors/warnings) versus intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Jul 26 '22 at 13:33
  • @Quinten, I changed the code to use mtcars. – overfieldc Jul 27 '22 at 06:18

0 Answers0