I am trying to plot two histograms in one plot, but the way these two groups are distributed makes the histogram a little hard to interpret. My histogram now looks like this:

This is my code:
hist(GROUP1, col=rgb(0,0,1,1/2), breaks=100, freq=FALSE,xlab="X",main="") # first histogram
hist(GROUP1, col=rgb(1,0,0,1/2), breaks=100, freq=FALSE , add=T) # second
legend(0.025,600,legend=c("group 1","group 2"),col=c(rgb(1,0,0,1/2),rgb(0,0,1,1/2)),pch=20,bty="n",cex=1.5)
Is it possible to plot this histograms, with the bars of the two groups right next to each other, instead of them overlapping? I realize that that might add some confusion, since the X-axis represents a continuous variable… Other suggestions of how to make this plot in more clear are of course also welcome!
You could misuse
barplotfor it:Example:
EDIT:
Here is an example to draw a x-axis like the OP suggested. IMHO this is very misleading (because bins of a barplot are not continuous values) and should not be used.
Please find the complete source code on github.