Skip to content

Instantly share code, notes, and snippets.

@martinctc
Created October 20, 2020 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinctc/a37937d3182c4c0fff87dd8a0cdece8c to your computer and use it in GitHub Desktop.
Save martinctc/a37937d3182c4c0fff87dd8a0cdece8c to your computer and use it in GitHub Desktop.
[geom label or text to align with geom_jitter()] #R
library(tidyverse)
library(hkdatasets)
hk_accidents %>% glimpse()
## These charts look ridiculous but at least the jitter points are aligned with the text
hk_accidents %>%
filter(Year == 2017) %>%
ggplot(aes(x = Natural_Light , y = No__of_Vehicles_Involved)) +
geom_violin() +
geom_jitter(position = position_jitter(seed = 1)) +
geom_text(aes(label = OBJECTID), position = position_jitter(seed = 1))
iris %>%
ggplot(aes(x = Sepal.Length, y = Species, fill = Species)) +
geom_violin() +
geom_jitter(position = position_jitter(seed = 1)) +
geom_label(aes(label = Species), position = position_jitter(seed = 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment