I am making a heatmap for some data and want to add a straight line between each set of samples. It seems like abline
doesn't work well on heatmap
.
Any idea what function I can use for this purpose?
You have to use the add.expr
argument. This example found here might be usefull:
x <- as.matrix(mtcars)
rc <- rainbow(nrow(x), start=0, end=.3)
cc <- rainbow(ncol(x), start=0, end=.3)
hv <- heatmap(x, col = cm.colors(256), scale="column",
RowSideColors = rc, ColSideColors = cc, margin=c(5,10),
xlab = "specification variables", ylab= "Car Models",
main = "heatmap(<Mtcars data>, ..., scale = \"column\")",
# IMPORTANT BIT HERE
add.expr = abline(h=5, v=2))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With