I am using
geom_label_repel to add country labels to my scatterplot. However, when using it to only show certain countries, it works for some but not all of them. See figure below. Here is my code:
ggplot(gft_k_im[gft_k_im$c_gft_k < quantile(gft_k_im$c_gft_k, c(.99)) & partner == "DEU"], aes(x=imp_sha, y=c_gft_k)) + xlim(0, 27) + ylim(0, 6.2) + geom_point(alpha=0.3, aes(size=imports, color=continenta)) + theme_ipsum() + labs(title="GFT vs. Imports Germany", x="Import Share (in %)", y = "Change in GFT (in %)") + labs(size = "Imports (in bn.)", color = "Continent") + geom_smooth(method=lm,se=FALSE) + geom_label_repel(aes(label = ifelse(country == c("FRA", "USA"),as.character(country),'')), min.segment.length = 0, box.padding = 0.1, point.padding = 0.5, segment.color = 'grey50', xlim = x_limits, ylim = c(-Inf, Inf))
As you can see, for USA and FRA it works well. However, when I select "CHN" then China does not show up even though it's in the data and can be displayed when using labeling techniques different from geom_label_repel. Why is that?