Created
October 20, 2020 21:34
-
-
Save martinctc/a37937d3182c4c0fff87dd8a0cdece8c to your computer and use it in GitHub Desktop.
[geom label or text to align with geom_jitter()] #R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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