Adding Vertical Lines to plot, "Error in int_abline(...) : plot.new has not been called yet"

My comment says annotate(geom = "text",..) the geom vline doesn't have a label argument

I'm sorry but you have me completely lost here, if you replace the "text" with what the label is supposed to be, it does not appear. Did you mean create another variable?

I mean add another annotation

data %>%
    filter(countriesAndTerritories %in% c("United_States_of_America", "Iran", "Italy")) %>% 
    arrange(countriesAndTerritories, dateRep) %>% 
    group_by(countriesAndTerritories) %>% 
    mutate(cum_cases = cumsum(cases)) %>% 
    filter(cum_cases >= 100) %>% 
    ggplot(aes(dateRep, cases, colour = countriesAndTerritories)) +
    geom_point() +
    scale_y_log10() +
    geom_smooth() +
    annotate(geom = "vline",
             x = as.POSIXct("2020-03-13"),
             xintercept = as.POSIXct("2020-03-13"),
             linetype="dotted",
             color = "blue",
             size=1.5) +
    annotate(geom = "text",
             x = as.POSIXct("2020-03-13"),
             y = 1000,
             label = "Hello",
             color = "black",
             angle = 90)

I think I see where you are going. For each line it must have an annotate container, and each label must also have an annotate container

If you are annotating your plot, yes, but if you want to map a variable to this aesthetics then use your previous approach with geom_vline() and geom_text().

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