Friday 1 November 2019

r - Avoid overlapping geom_point and geom_text in ggplot2

How can I avoid that these 2 layers in ggplot2 overlap? I try to display the text so that they are not laying above the points.


check_overlap does a great job with avoiding that the text overlaps itself, but not with other layers.


I also tried the library geom_text_repel, but this library does not support check_overlap and shows the text for every data point.


But I need to not have the text for every point, like check_overlap does.


ggplot(dat, aes(x = CPI, y = HDI)) +
geom_point(aes(color = Region), shape=21, size=4, position = "identity") +
geom_text(data = dat, aes(label = Country), size=4, check_overlap = TRUE)

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...