geom_text_repel
doesn’t display the labels for several several points where y is 0:
However, I’m able to adjust geom_text
to get the labels inside the plot:
Do y’all know how to get the labels using geom_text_repel
? Please find my code below:
df <- structure(list(country = c("Afghanistan", "Maldives", "South Korea",
"Myanmar", "Hong Kong", "Nepal", "Iran", "Pakistan", "Mongolia",
"Sri Lanka", "Solomon Islands", "Papua New Guinea", "Philippines",
"Vanuatu", "Fiji", "India", "Thailand", "Bangladesh", "Timor-Leste",
"Cambodia", "Bhutan", "Indonesia", "Malaysia", "North Korea",
"China", "Laos", "Vietnam"), events_100k = c(3.98929763342097,
2.79873668427856, 2.62575870183105, 2.35641546264502, 1.82589571721442,
1.5246135146153, 0.911935371211704, 0.732282427564865, 0.732173241902643,
0.696527510433654, 0.558478859194678, 0.533576507194829, 0.437436665635902,
0.372548653981312, 0.332483712390482, 0.33108510506144, 0.287659607432814,
0.268114542694623, 0.243799197500219, 0.225647112496632, 0.214237892068302,
0.161625916810053, 0.122442381076969, 0.030958809775498, 0.0305411355867934,
0.0265856721537317, 0.0110560302970689), fatalities_100k = c(13.5403363662492,
0, 0, 2.40734372064802, 0.00103111295706451, 0.0176525607421717,
0.101916026586642, 0.281265249931412, 0.00121560201851201, 0.0427296136131635,
0.126203591830265, 0.617302833700826, 0.470032459501862, 0.0340059714485864,
0, 0.0248378913598791, 0.0649046751582995, 0.0595271434968146,
0.0176774482270748, 0.0142209364310508, 0, 0.0134710052425114,
0.00593122835659716, 0.0163140899407196, 0.000259674902575946,
0.0143455539400826, 0.00158666022175559)), row.names = c(NA,
-27L), class = c("tbl_df", "tbl", "data.frame"))
df |>
select(-events, -fatalities) |>
ggplot(aes(x = events_100k, y = fatalities_100k)) +
geom_point() +
geom_text(aes(label = country), vjust = "inward") +
# ggrepel::geom_text_repel(aes(label = country), vjust = "inward") +
scale_x_log10() +
scale_y_log10()