-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add show_warning argument #263
base: master
Are you sure you want to change the base?
Conversation
I have come across this warning rather frequently, but the simple solution in most cases is to increase max overlaps (Inf is accepted). There is parameter |
The point is that I don't want to increase I am of course open to any modifications to my code suggestion as long as it would still allow the user to somehow silence warnings. The problem for me is just that there is currently no way of silencing warnings of this package, which should be always possible. I use |
Hi @jpquast and thank you for the PR. I'm not sure why Here is a reprex that (sometimes) seems to reproduce the issue that was described in #187 : library(ggrepel)
d <- mtcars
d$label <- rownames(d)
#' Here we get a warning that we expect.
p <- ggplot(d) +
geom_point(aes(wt, mpg)) +
geom_text_repel(aes(wt, mpg, label = label), size = 20)
p
#' This (sometimes) prints more than one warning.
p
#' This (sometimes) prints the warnings again, even though they were already printed.
set.seed(2)
#' This does not suppress the warnings, even though we would expect it to suppress them.
suppressWarnings({ p }) Sometimes, I get one warning, but sometimes I get more than one. I'm not sure how to reproducibly get multiple warnings.
I can see why this would be a problem, and maybe the simplest workaround is the addition of the I'm a bit confused why we can't suppress these warnings. I have an inkling that maybe this has to do with the location of the call to For me, |
Hi @slowkow, thanks for your reply! the problem that your are describing is exactly the issue I have as well. I originally wanted to post a reprex, but it was simply not reproducible. I unfortunately don't understand enough of geom constructor functions to know a better way to implement these warnings. The only solution that would work is to not even generate the warning as far as I can see for now. In ggplot they generally seem to use |
@slowkow If the pull request is accepted the parameter could be called |
Not sure I understand the problem 100%, but here are some quick thoughts. At least part of the problem why Secondly, the warnings are dynamically generated every time grid draws the figure, which delays these warnings beyond the |
Thanks for the comment! This is consistent with what I was thinking. I tried some hacks, but I don't think there is a way to move the Therefore, I think the only way to address this is the way that @jpquast has done it, with an option to the I feel that our usage of Right now I am considering two options for how to proceed: Option 1Accept the PR by @jpquast to add an argument just for the warnings. I think I might suggest Considering that the warnings seem to be a nuisance for most users, I am starting to think that they should be off by default. Please share your thoughts. I want to avoid disturbing developers who depend on ggrepel. Option 2Use the
And we'll set I feel like one argument ( I favor Option 2, but I'm willing to consider your thoughts @jpquast @aphalo @teunbrand |
@slowkow @jpquast I agree with Kamil: I like option 2 better than option 1. I suggest making the default
|
@slowkow @aphalo I also agree with both of you. I think option 2 is the most intuitive one. At least I was hoping I could use |
OK, I think I have a working version of the code that implements what we discussed: |
Great thanks! I tested it and it successfully removes the warnings in my package tests. |
This addresses issue #187.
I have the same problem with warnings from
ggrepel
showing up in unexpected places. I don't manage to suppress them either withSuppressWarnings()
. Therefore, I added an additional argument togeom_text_repel()
andgeom_label_repel()
calledshow_warning
that allows the user to disable the display of warnings. The default isTRUE
so that there is no change from the current behaviour.