Skip to content

Extend the plot range of geom_density() nicely #3716

Closed as not planned
Closed as not planned
@yutannihilation

Description

@yutannihilation

(See #3708 (comment))

Compared to the base R's density plot, geom_density() draws in a narrower range. As a result, the line doesn't touch the X-axis. Though it needs a lot of care to extrapolate the data correctly, it's nice if geom_density() can draw the bottom right one below.

plot(density(diamonds$carat, adjust = 5))

p <- ggplot(diamonds, aes(carat)) +
  geom_density(adjust = 5)

patchwork::wrap_plots(
  p + ggtitle("(default)"),
  p + ggtitle("(expanded)") + expand_limits(x = -0.5)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions