ggalt
ggalt copied to clipboard
`ash1()` never sees `m` and `kopt`
The following code should produce (nearly¹) overlapping histograms:
faithful |>
ggplot2::ggplot(ggplot2::aes(x = eruptions)) +
ggplot2::stat_bin(
closed = "right",
breaks = breaks,
mapping = ggplot2::aes(y = ggplot2::after_stat(density)),
fill = NA,
color = "blue"
) +
ggalt::stat_ash(
nbin = 18,
ab = range(breaks),
m = 1,
geom = "bar",
fill = NA,
color = "red"
)
...but it doesn't:
The reason is that ash::ash1()
is never provided with m
(or kopt
), but is rather always called with the default m = 5
:
https://github.com/hrbrmstr/ggalt/blob/30dc0dade4d0b8d78eddea7409a07f86dbbafa76/R/geom_ash.r#L115-L127
¹ In theory, the histograms should align perfectly. In practice, ash::bin1()
differs from graphics::hist()
, e.g. compare ash::bin1(faithful$eruptions, ab = c(1.6, 5.2), nbin = 18)$nc
and hist(faithful$eruptions, breaks = 18, right = TRUE, plot = FALSE)$counts
.