ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Change density default `bw = "nrd0"` to `bw = "sj"`

Open teunbrand opened this issue 2 months ago • 5 comments

This PR aims to fix #3825.

Briefly, ?density recommends the "sj" method over the "nrd0" default. This change propagates that recommendation to ggplot2's density calculations.

Some details:

  • Understandably, plenty of snapshots have changed.
  • I realised that calc_bw() and precompute_bw() were doing the exact same task, so I merged these.
  • When var(x) == 0, most of the stats::bw.*() functions throw an error, so we keep bw.nrd0() for these degenerate cases because it will not throw an error.

teunbrand avatar Apr 22 '24 08:04 teunbrand