Home > Software engineering >  How do I merge a geom_bar and a dpois stat_function together in r?
How do I merge a geom_bar and a dpois stat_function together in r?

Time:05-10

I'm trying to merge my 2 plots in r. I currently have 2 ggplots like so:

ggplot(dataset2, aes(x = factor(V1)))  
    geom_bar(alpha = 0.2)
    
ggplot(dataset2, aes(V1))  
    stat_function(geom="line", n=10, fun=dpois, args=list(1.602))

This gives me the plot: enter image description here


Data used

set.seed(1)
dataset2 <- data.frame(V1 = rpois(100000, 1.602))
  • Related