0

I have a distribution as shown below.

First, how do I avoid half bins? It seems even with setting the binwidth to a manual value I still get them.

Secondly, can I use geom_density to smoothe over exponential-like distributions AND gaussian-like distributions, in the same data set? I'm plotting several different distributions with facet_wrap, but the standard KDE only looks good for gaussian-like distributions without too much skew.

Edit: dput sample data: https://pastebin.com/anezb1SZ

And the code

ggplot(data = Test, aes(x = Test,
                        y = ..density..)) +
    geom_density(alpha = 0,
                 col = "black") +
    geom_histogram(alpha = 0.7,
                   col = "black",
                   binwidth = 2e-9) +
    scale_fill_discrete() +
    scale_y_continuous(expand = c(0,0),
                       breaks = c(0, 1.5e8, 3e8)) +
    scale_x_continuous(expand = c(0,0)) +
    coord_cartesian(xlim = c(1e-15,3.5e-8),
                    ylim = c(0,1.5e8)) +
    theme_classic()

enter image description here

komodovaran_
  • 1,940
  • 16
  • 44

0 Answers0