Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change density default bw = "nrd0" to bw = "sj" #5854

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

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 teunbrand added the breaking change ☠️ API change likely to affect existing code label Apr 22, 2024
@thomasp85
Copy link
Member

I'm not sure I think this is worth the breaking change to be honest... I probably miss a compelling example of when it would improve a visualisation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ☠️ API change likely to affect existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change default for bw arg of stat_density() and stat_ydensity()
2 participants