Simple example fails with ggplot2 3.3.3

This code sample works fine with ggplot2 3.3.0

ggplot(NULL, aes(x = c(-20, 20))) +
  stat_function(fun = function(x) { x**3 },
                geom = "line")

But with 3.3.3 generates this error

Error: Aesthetics must be either length 1 or the same as the data (1): x

ggplot(data.frame(x = c(-20, 20))) +
  aes(x = x) +
  stat_function(fun = function(x) {x**3},
                geom = "line")

Hmmm, NULL is not a data.frame. what would fortify() do if passed NULL?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Thanks that works but I'm wondering why the change in behavior from earlier versions of the package. I also have an environment with a 3.3.2 ggplot2 version that throughs the error without the explicit use of data.frame but the documentation says:

Usage
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

data
Default dataset to use for plot. If not already a data.frame, will be converted to one by fortify(). If not specified, must be supplied in each layer added to the plot.