phantom lines GGPlot

Hello,
The following data and plot produce a phantom double line in the geom_line call. This code and data structure work for every other town I'm working on- just this one town the plot is rendering with the double line. When I just plot the geom_line - the line is smooth. It's the overlay that is making it double. Any ideas?

library(tidyverse)
Burlington <- structure(list(IncidentYear = c(2019, 2020, 2021, 2022, 2019, 
2020, 2022, 2019, 2020, 2021, 2022, 2019, 2020, 2021, 2022), 
    totalOD = c(43, 69, 106, 151, 43, 69, 151, 43, 69, 106, 151, 
    43, 69, 106, 151), offense_category_name = c("Assault Offenses", 
    "Assault Offenses", "Assault Offenses", "Assault Offenses", 
    "Homicide Offenses", "Homicide Offenses", "Homicide Offenses", 
    "Kidnapping/Abduction", "Kidnapping/Abduction", "Kidnapping/Abduction", 
    "Kidnapping/Abduction", "Sex Offenses", "Sex Offenses", "Sex Offenses", 
    "Sex Offenses"), Total = c(398L, 399L, 370L, 348L, 4L, 2L, 
    5L, 12L, 8L, 12L, 9L, 60L, 57L, 28L, 16L)), row.names = c(NA, 
-15L), class = c("tbl_df", "tbl", "data.frame"))
#>    IncidentYear totalOD offense_category_name Total
#> 1          2019      43      Assault Offenses   398
#> 2          2020      69      Assault Offenses   399
#> 3          2021     106      Assault Offenses   370
#> 4          2022     151      Assault Offenses   348
#> 5          2019      43     Homicide Offenses     4
#> 6          2020      69     Homicide Offenses     2
#> 7          2022     151     Homicide Offenses     5
#> 8          2019      43  Kidnapping/Abduction    12
#> 9          2020      69  Kidnapping/Abduction     8
#> 10         2021     106  Kidnapping/Abduction    12
#> 11         2022     151  Kidnapping/Abduction     9
#> 12         2019      43          Sex Offenses    60
#> 13         2020      69          Sex Offenses    57
#> 14         2021     106          Sex Offenses    28
#> 15         2022     151          Sex Offenses    1
BTVplot <- Burlington %>% 
  ggplot(aes(x= IncidentYear, fill= offense_category_name, y = Total))+
  geom_bar(stat = "identity")+
  geom_line(aes(y=totalOD), linewidth = .5) +
  scale_fill_brewer(palette = "Dark2")+
  labs(title = "Burlington Violent Crimes and Total Overdoses", x = "Incident Year",
       fill = "Type of Crime") +
  theme_minimal()
BTVplot

The attached screen shot is the output - with the phantom line starting in 2020

Thank you for any insights.

I suppose the easiest fix here is to add fill=NULL to the aes of the geom_line

Thank you! That worked!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.