yutannihilation / gghighlight

Highlight points and lines in ggplot2
https://yutannihilation.github.io/gghighlight/
Other
522 stars 23 forks source link

Use geomtextpath and secondary axis to add labels #185

Closed yutannihilation closed 1 year ago

yutannihilation commented 2 years ago
devtools::load_all("~/GitHub/gghighlight")
#> ℹ Loading gghighlight
#> Loading required package: ggplot2

d <- data.frame(x = c(1:3, 1:3, 1:3), y = c(1:3, 2, 4, 2, 0, 1, 1), id = c("a", "a", "a", "b", "b", "b", "c", "c", "c"))

p <- ggplot(d) +
  geom_line(aes(x, y, colour = id))

p + gghighlight(max(y) >= 3, line_label_type = "text_path", label_params = list(size = 10))
#> label_key: id

p + gghighlight(max(y) >= 3, line_label_type = "label_path", label_params = list(size = 10))
#> label_key: id

p + gghighlight(max(y) >= 3, line_label_type = "sec_axis")
#> label_key: id

Created on 2022-07-24 by the reprex package (v2.0.1)