plot – Side by Side histograms in the Same Graph in R?

plot – Side by Side histograms in the Same Graph in R?

The example comes from using the plotrixpackage. Code was found here. You will first need to install that package before you can access the multihist function:

n

#install.packages(plotrix)nrequire(plotrix)nnl <- list(rnorm(50),rnorm(50,sd=2),rnorm(50,mean=3))nmulthist(l)n

n

enter

Here is the ggplot version of this graph.

n

require(ggplot2)nrequire(reshape2)nnset.seed(1)ndf <- data.frame(x = rnorm(n = 1000, mean = 5, sd = 2),n                 y = rnorm(n = 1000, mean = 2),n                 z = rnorm(n = 1000, mean = 10))nnnnggplot(melt(df), aes(value, fill = variable)) + geom_histogram(position = dodge)n

n

enter

plot – Side by Side histograms in the Same Graph in R?

Leave a Reply

Your email address will not be published.