I have a boxplot graph where I want to show label names. The problem is that I want to repel these label names to make them beyond the boxplot. I tried geom_text_repel
from ggrepel
package but it repels lables when they overlap each other.
Also tried advice like this: Repel geom label and text in ggplot. And ordering geom points based on size
And have not received any comprehensive info about solving my problem.
Sample:
mtdata <- mtcars %>%
rownames_to_column(var = "name") %>%
mutate(cyl = as.factor(cyl))
ggplot(mtdata, aes(x = cyl, y = mpg)) + geom_boxplot() +
geom_text_repel(data = mtdata %>%
filter(mpg > 20 & wt >3), aes(label = name))
Desirable output:
So, you can see that there is a dot which depicts exact label position and repelling.