-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
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.
Lines 68 to 71 in 3870c12
| # Warn if supplied mapping and/or data is going to be overwritten | |
| if (!is.null(mapping)) { | |
| warning("`mapping` is not used by stat_function()", call. = FALSE) | |
| } |
library(ggplot2)
ggplot(data.frame(x = 0), aes(x = x)) +
stat_function(aes(color = "linear"), fun = function(x) x) +
stat_function(aes(color = "quadratic"), fun = function(x) x*x) +
xlim(-5, 5)
#> Warning: `mapping` is not used by stat_function()
#> Warning: `mapping` is not used by stat_function()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.
jan-glx
