I am using the histbackback function from the Hmisc package to generate two back-to-back histograms. I managed to add colors to the bars, but I did not manage to add density lines to both histograms.
Could someone help me out? Here is the code I have tried so far.
library(Hmisc)
hbb <- histbackback(pre, post, brks=seq(0.0001, 0.20, by=0.01))
barplot(-hbb$left, col="lightgrey", horiz=TRUE, space=0, add=TRUE, axes=FALSE)
barplot(hbb$right, col="darkgrey", horiz=TRUE, space=0, add=TRUE, axes=FALSE)
# works until here but now I cannot add lines
lines(density(pre), # density plot,
horiz=TRUE, space=0, add=TRUE, axes=FALSE)