You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rendering a plot with a geom_smooth() geom and a size aesthetic, I get a warning message that using size for lines has been deprecated and that the size aesthetic is being dropped. In the past, geom_smooth() ignored the size aesthetic without generating any warnings. Is it necessary to generate a warning in this case, given the behavior has not changed from past versions?
library(ggplot2)
ggplot(mtcars, aes(x=hp, y=mpg, size=cyl)) +
geom_point() +
geom_smooth()
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.#> ℹ Please use `linewidth` instead.#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'#> Warning: The following aesthetics were dropped during statistical transformation: size#> ℹ This can happen when ggplot fails to infer the correct grouping structure in#> the data.#> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical#> variable into a factor?
In the past geom_smooth() ignored the size aesthetic by accident, due to this bug: #3250
In fact, the second warning you get, "The following aesthetics were dropped ...", informs you that size was dropped purely because it is not constant across the group, which is usually a sign that something has gone wrong. This warning is also new since the latest ggplot release.
The correct way of addressing both warnings is to supply the size aesthetic only to geom_point().
library(ggplot2)
ggplot(mtcars, aes(x=hp, y=mpg)) +
geom_point(aes(size=cyl)) +
geom_smooth()
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
When rendering a plot with a
geom_smooth()
geom and asize
aesthetic, I get a warning message that usingsize
for lines has been deprecated and that thesize
aesthetic is being dropped. In the past,geom_smooth()
ignored thesize
aesthetic without generating any warnings. Is it necessary to generate a warning in this case, given the behavior has not changed from past versions?Created on 2023-02-08 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: