Expanding the response to danger, here is a small function that will automatically detect which bin contains the value you want to highlight:
highlight <- function(x, value, col.value, col=NA, ...){ hst <- hist(x, ...) idx <- findInterval(value, hst$breaks) cols <- rep(col, length(hst$counts)) cols[idx] <- col.value hist(x, col=cols, ...) }
Now
x <- rnorm(100) highlight(x, 1.2, "red")
will highlight a cell with 1.2 in it in red.
Aniko
source share