What are the ways of imposing one histogram on another besides the gglot and the parameter add = T in R?

  • What's the point? gglot or hist (h2, add = T) is enough - Yury Arrow
  • 2
    You can use lattice , plotly , rbokeh , ggvis . The key question is why? - Ogurtsov

1 answer 1

In the comments to the question rightly ask - "why?".

If there is a task to compare the distribution of a variable across some groups, it is better to use geom_density

 library(viridis) library(ggplot2) gg_dens <- ggplot(airquality)+ geom_density(aes(x = Temp, color = factor(Month)))+ scale_color_viridis(option = "B", discrete = T, end = .8)+ theme_minimal()+ theme(legend.position = c(.8,.8)) 

enter image description here


In my opinion, it is even more convenient to visually compare the accumulated distributions - empirical cumulative density ( stat_ecdf ).

 gg_ecdf <- ggplot(airquality)+ stat_ecdf(aes(x = Temp, color = factor(Month)))+ scale_color_viridis(option = "B", discrete = T, end = .8)+ theme_minimal()+ theme(legend.position = c(.1,.8)) 

enter image description here

  • There about "besides ggplot2" it is asked, from here bewilderment. - Ogurtsov
  • Really. Then it is even more doubtful what is needed at all - ikashnitsky