Hi, can you have the same line pass through different shapes in a ggplot?
For example:
library(tidyverse)
library(lubridate)
df <- tibble::tribble(
~SAMPLE_DATE, ~REPORT_RESULT_VALUE, ~DETECT_FLAG,
"2010-01-29", 0.5, "N",
"2018-10-05", 0.28, "Y",
"2019-05-03", 0.65, "Y",
"2019-10-05", 0.15, "N",
"2020-06-02", 0.23, "Y",
"2020-09-12", 0.15, "N",
"2021-04-24", 0.15, "N",
"2021-08-25", 0.15, "N",
"2022-05-04", 0.4, "Y"
) %>%
mutate(SAMPLE_DATE = ymd(SAMPLE_DATE))
ggplot(df, aes(SAMPLE_DATE, REPORT_RESULT_VALUE, shape = DETECT_FLAG)) +
geom_line() +
geom_point() +
scale_shape_manual(values = c("N" = 1, "Y" = 19))
Ideally this would just be one line:
Like this, but with the shapes: