I am trying to plot two histograms using histbackback and then adding
color to each of the samples. The code I have seen on the R graph
gallery suggests the following method of using histbackback
require(Hmisc)
age <- rnorm(1000,50,10)
sex <- sample(c('female','male'),1000,TRUE)
out <- histbackback(split(age, sex), probability=TRUE, xlim=c(-.06,.06),
main = 'Back to Back Histogram')
#! just adding color
barplot(-out$left, col="red" , horiz=TRUE, space=0, add=TRUE,
axes=FALSE)
barplot(out$right, col="blue", horiz=TRUE, space=0, add=TRUE,
axes=FALSE)
I get the following message when I execute the snippet to add color
Warning messages:
1: parameter "add" could not be set in high-level plot() function
2: parameter "add" could not be set in high-level plot() function
Any help would be appreciated.
[[alternative HTML version deleted]]