Closed
Description
When plotting with an empty data (which may happen when filtering goes wrong), there is an error if constant aesthetics are mixed with column names, and the error message is a little confusing.
Example:
> ggplot(head(mtcars, 0)) + geom_point(aes(x = hp, y = mpg)) # no error here, plot is empty
> ggplot(head(mtcars, 0)) + geom_point(aes(x = 3, y = 4)) # no error here, plot contains one point
> ggplot(head(mtcars, 0)) + geom_point(aes(x = 3, y = mpg)) # error!
Fehler: Aesthetics must be either length 1 or the same as the data (1): y
Run `rlang::last_error()` to see where the error occurred.
Taken literally, the error message is wrong: Aesthetics y
does have the same length as the data (0).
Expected behaviour: No error message, return an empty plot.