# compare two normal distributions with means that differ a lot
# in this case, the overlap will not be observed
set.seed(123)
compHist(
x1 = rnorm(1000, mean = 3),
x2 = rnorm(1000, mean = 10),
title = "Histogram of Distributions With Means 3 & 10",
col1 = "yellow", col2 = "violet"
)
# compare two normal distributions with means that are close
# in this case, the overlap between the histograms will be observed
set.seed(123)
compHist(
x1 = rnorm(1000, mean = 0),
x2 = rnorm(1000, mean = 2),
title = "Histogram of rnorm Distributions With Means 0 & 2",
col1 = "lightslateblue", col2 = "salmon"
)
set.seed(123)
# separate the plots for preview
compHist(
x1 = rnorm(1000, mean = 0),
x2 = rnorm(1000, mean = 2),
title = c("Plot Means 0", "Plot Means 2"),
col1 = "#F96167", col2 = "#CCF381",
separate = TRUE
)
Run the code above in your browser using DataLab