Closed arodionoff closed 5 months ago
I'm facing the same issue. geom_label
works as expected, but geom_label_repel
shows no labels in 0.9.5
. 0.9.4
works as well, 0.9.5.9999
does not.
This issue is related to: #253 #255 #257 #260
Commit 4119c28957e956ad39d65254a4ce76377ed0e5ae should fix it.
library(apyramid)
library(ggrepel)
#> Loading required package: ggplot2
data(us_2018)
df <- us_2018
df$count <- ifelse(df$gender == 'male', -df$count, df$count)
# using ggrepel::geom_text_repel()
age_pyramid(us_2018, age_group = "age", split_by = "gender", count= 'count') +
geom_text_repel(
data = df,
mapping = aes(x = age, y = count, label = paste0(percent, '%')),
size = 5,
position = position_nudge_repel(y = ifelse(df$gender == "female", 100, -100))
) +
scale_y_continuous(expand = expansion(mult = 0.2))
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.
# using ggplot2::geom_text()
age_pyramid(us_2018, age_group = "age", split_by = "gender", count= 'count') +
geom_text(
data = df,
mapping = aes(x = age, y = count, label = paste0(percent, '%')),
size = 5,
position = position_nudge(y = 3e3 * ifelse(df$gender == "female", 1, -1))
) +
scale_y_continuous(expand = expansion(mult = 0.2))
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.
Created on 2024-05-16 with reprex v2.0.2
Summary
Behaviour difference between new vs. old version of your package. The labels are produced with ‘ggrepel’ version 0.9.4, but not with version 0.9.5 on Windows & Ubuntu (I do not have any Mac computer).
Minimal code example
Here is the minimum amount of code needed to demonstrate the issue:
Here is an image of the output produced by the code:
Suggestions
Eliminate the reasons for the lack of text output in the new version of the package.
Version information
Here is the output from
sessionInfo()
in my R session: