Skip to content

Fix error message for geom_density() when using yΒ #3514

@Maschette

Description

@Maschette

Hi,
The error message for geom_density() when using x and y comes up and says y is missing. My suggestion would be to change the error when x and y are present but stat is not identity to "y is present, did you mean to use stat = 'identity'" or something like that. Also adding an example that uses x and y to https://ggplot2.tidyverse.org/reference/geom_density.html would be great.

x<-data.frame(value=seq(0,1,by=0.2), count=rnorm(6, mean = 10) )

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.6.1

ggplot(x)+geom_density(aes(x=value, y=count))
#> Error: geom_density requires the following missing aesthetics: y

ggplot(x)+geom_density(aes(x=value, y=count), stat = 'identity')

Created on 2019-09-02 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions