Skip to content

Change default for bw arg of stat_density() and stat_ydensity() #3825

Closed as not planned
@richierocks

Description

@richierocks

In the ?density help page, the description for the bw argument states:

The default, "nrd0", has remained the default for historical and compatibility reasons, rather than as a general recommendation, where e.g., "SJ" would rather fit, see also Venables and Ripley (2002).

stat_density() and stat_ydensity() use density()'s default of "nrd0". Since ggplot2's philosophy is to provide the "best" default wherever possible, it seems like a good idea to change the default for these functions to bw = "SJ".

I'm not an expert in KDE algorithms, so I can't verify if the claim in the ?density page is true or not, but I thought it worth opening up the discussion.

If you decide to change the default for those functions, it also needs changing in the compute_group() and compute_density() methods of the StatDensity and StatYdensity ggproto objects.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions