**Data Analysis and Visualization in R**, and kindly contributed to R-bloggers)

While preparing a class exercise involving the use of overlaying of histogram, I searched *Google* on possible article or discussion on the said topic. Luckily, I found a blog where the author demonstrated an R function to create an overlapping histogram. However, a comment from a guy also showed the same output using transparency. Below were the sample codes that can be used to generate overlapping histogram in R as based on the blog and the viewers comment.

Here are the codes:

#Random numbers

h2<-rnorm(1000,4)

h1<-rnorm(1000,6)

# Histogram Grey Color

hist(h1, col=rgb(0.1,0.1,0.1,0.5),xlim=c(0,10), ylim=c(0,200), main=”Overlapping Histogram”)

hist(h2, col=rgb(0.8,0.8,0.8,0.5), add=T)

box()

# Histogram Colored (blue and red)

hist(h1, col=rgb(1,0,0,0.5),xlim=c(0,10), ylim=c(0,200), main=”Overlapping Histogram”, xlab=”Variable”)

hist(h2, col=rgb(0,0,1,0.5), add=T)

box()

**leave a comment**for the author, please follow the link and comment on their blog:

**Data Analysis and Visualization in R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...