Hist
I find myself always rewriting this code, so instead I will post it.

It is code to make a solid histogram with a thick outline, which is useful to overlay two empirical distributions or if you want to change the x axis to log for example.
x = rnorm(1000)
h = hist(x,breaks=20,plot=FALSE)
brks = rep(h$breaks,each=2)
counts = c(0,rep(h$counts,each=2),0)
plot(brks,counts,type="n",xlab="Value",ylab="Frequency",main="Histogram")
lines(brks,counts,lwd=2)
polygon(brks,counts,col=rgb(1,1,0,.5))
leave a comment