Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text is double printed with ggbreak when using geom_repel_text #56

Open
johnnl15 opened this issue Nov 1, 2022 · 6 comments
Open

Text is double printed with ggbreak when using geom_repel_text #56

johnnl15 opened this issue Nov 1, 2022 · 6 comments

Comments

@johnnl15
Copy link

johnnl15 commented Nov 1, 2022

Hi, i'm having this issue where the text is printed twice. Would appreciate advice on how to get around this:

require(ggplot2 )
require(ggbreak)
require(ggrepel)
set.seed(2019-01-19)
d <- data.frame(
x = 1:20,
y = c(rnorm(5) + 4, rnorm(5) + 20, rnorm(5) + 5, rnorm(5) + 22)
)

d$label<-"hello"
d$label[d$x!=7]<-NA
p <- ggplot(d, aes(x, y,label=label)) + geom_point() + geom_text_repel()+
scale_y_break(c(7, 17 ))
print(p)

image

@phancanhtrinh
Copy link

I have the same problem. Can anyone know how to solve this? Thank you very much

@shanshenbing
Copy link

I get same issue. Any help will be appreciated.

@jmburgos
Copy link

Same issue here. :)

@jamiahuswalton
Copy link

I am getting the same issue here. Any help would be greatly appreciated. I really like geom_repel_text better than geom_text.

Any help would be greatly appreciated!

@pormr
Copy link

pormr commented Nov 22, 2023

Unlike ordinary facetting function, ggbreak seems to take a different approach to splitting axes, which is incompatible with ggrepel.
However, you can still use facet_grid() with space = "free_*" and scales = "free_*" to split the plot while preventing the same labels from appearing twice:

p <- ggplot(d, aes(x, y)) +
  geom_point() +
  geom_blank(data = data.frame(x = Inf, y = c(7, 17))) +
  geom_text_repel(aes(label = label)) +
  facet_grid(vars(y <= 7), space = "free_y", scales = "free_y") +
  theme(strip.background = element_blank(),
        strip.text = element_blank())

print(p)

image

Tips: geom_blank can sometimes be useful, especially when you want to extend the limit of axes.

@yuanlinm
Copy link

Note: This issue was not caused by the ggbreak package, but rather due to an update in the ggrepel package.

This problem occurred in the latest update of the ggrepel R package (2024-09-07 in CRAN, 2024-09-08 in Github, 0.9.6), and can be solved with the older version (2024-01-11 in Github, 0.9.5). You can use the codes below to remove the current version and install the older version.

# remove current one
remove.packages("ggrepel")

# dowload the 0.9.5 ggrepel source code from github (ggrepel-0.9.5.tar.gz)

# install older one
install.packages("~Downloads/ggrepel-0.9.5.tar.gz", repos = NULL, type = "source")

# load
library(ggrepel)

Your problem will be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants