The problem
I am trying to replicate the text alignment and even spacing as in hjust = 0
panel from the ggrepel examples:
My plot
The difficulty is that I have concatenated multiple string into single labels so that the line segments don't make the plot look too messy. These larger labels don't seem to be playing well with one another:
The data
nest_data <- structure(list(rate = c(27, 25, 24, 23, 22, 21, 20, 19, 18, 17,
16, 15, 10, 8, 7.7, 5), country_groups = c("Hungary", "Denmark\n Norway\n Sweden",
"Finland\n Greece\n Iceland", "Ireland\n Poland\n Portugal",
"Italy\n Slovenia", "Belgium\n Czech Republic\n Latvia\n Lithuania\n Netherlands\n Spain",
"Austria\n Estonia\n France\n Slovak Republic\n United Kingdom",
"Chile\n Germany", "Turkey", "Israel\n Luxembourg", "Mexico",
"New Zealand", "Australia\n Korea", "Japan", "Switzerland", "Canada"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-16L))
My attempt
(nest_data_vat_plot <- ggplot(nest_data, aes(y = rate, x = 1, label = country_groups)) +
geom_point(color = "red") +
theme(
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.text.x = element_blank(),
axis.title.x = element_blank(),
plot.title = element_text(hjust = 0),
panel.background = element_blank()
) +
xlim(1, 1.1) +
geom_text_repel(
nudge_x = 0.035,
direction = "y",
hjust = 0
) +
scale_y_continuous(breaks = seq(2.5, 30, 2.5)) +
labs(
title = "Consumption tax rates",
caption = "Source: OECD Tax Stats \n2019 data presented \nRef: oecd_vat_gst_rates.R",
x = "",
y = ""
))