-
Notifications
You must be signed in to change notification settings - Fork 2.1k
stat_function() produces incorrect warning #3611
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
Comments
Could it be tweaked to say that positional mapping is ignored? |
I guess we could inspect the mapping and create a warning if positional aesthetics are used. |
Pinging @paleolimbot as he suggested the warning in the first place. Any thoughts on this from you? In the linked discussion, I see mentioning of the |
Whoops, that was me! Using I seem to remember that the issues are caused when |
A related issue arises with library(ggplot2)
ggplot(data.frame(x = 0), aes(x = x)) +
geom_abline(intercept=0, slope = 1, aes(color="true value"))
geom_abline(): Ignoring `mapping` because `slope` and/or `intercept` were provided.
Warning message:
In geom_abline(intercept = 0, slope = 1, aes(color = "true value")) :
Using `intercept` and/or `slope` with `mapping` may not have the desired result as mapping is overwritten if either of these is specified But here a simple workaround is possible by specifying ggplot(data.frame(x = 0), aes(x = x)) +
geom_abline(aes(intercept=0, slope = 1, color="true value")) Not sure if this belongs here, but I'm leaving this here since that was the only relevant page that showed up googling above error message and using Some thoughts on this issue itself: |
What is the status of this one? I second the latest suggestion: why is the warning not disappearing when |
Just came across this on Stackoverflow: @paleolimbot If the concern is that some mappings create multiple copies of the function, then I'm not sure the current warning addresses that issue, because most people won't make the connection between the warning and that problem. Instead, it seems to me that what we need is a |
@clauswilke absolutely the right way to go! Let me know if there's something I can help with to get the patch release out the door. |
@paleolimbot Please take a look here: #3982 and let me know what you think. |
* Implement geom_function(). Closes #3611. * update unit test * rename test file, check for empty data * improve documentation * consolidate news items
@jan-glx The point you're making regarding |
Uh oh!
There was an error while loading. Please reload this page.
stat_function()
generates a warning whenever a mapping is provided, but then it uses the mapping as normal.These are the relevant lines in the code, and a reprex follows below.
ggplot2/R/stat-function.r
Lines 68 to 71 in 3870c12
Created on 2019-11-04 by the reprex package (v0.3.0)
I'm not sure whether there are cases where the warning is useful. I would propose to delete it. It's probably too complicated to try to find out whether the mapping is meaningful or not in the given context.
The text was updated successfully, but these errors were encountered: