Problem for add key color/legend on heat map graphic

Hello R studio community,
I have just a little problem with my Heatmap representation. I need to have a key color for know the strong correlation between "variables" and "sites". But I don't find how to make these with heatmap function and Rstudio help.
Please find at the end of these post the script for a reproductible example.
Thank you for your help
Roxane

require(graphics);
require(grDevices)
library(colorRamps)

data<-dune

x <- as.matrix(data)
rc <- rainbow(nrow(x), start = 0, end = .2)
cc <- rainbow(ncol(x), start = 0, end = .2)
hv <- heatmap(x, col = blue2yellow(n)(n), scale = "column",
RowSideColors = rc, ColSideColors = cc, margins = c(5,10),
xlab = "Variables", ylab = "Sites")
utils::str(hv)
heatmap(x, Rowv = NA, Colv = NA, col = blue2yellow(n), scale = "column", margins = c(5,10),
xlab = "Variables", ylab = "Sites")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.