Hi,
I am generating a few heatmaps using ggplot2 using the following code.
ggplot(zscore.m, aes(variable, factor(EXT,levels=unique(EXT)))) + geom_tile(aes(fill = value,position="fill"),colour = "white") +scale_fill_gradientn(colours=c("white","orange","red","dark red"))
The scale is determined based on the values in the data (here zscore.m
). Lets say the scale in one of the heatmap ranges from -5 to 5
and the other heatmap ranges from -8 to 8
. The colour scale is adjusted accordingly. What I would like is to have is same colours for similar values, so both the heatmaps can be compared visually w/o having to refer to the scale time and again.
Thanks in advance for your help!
It's not clear if you want the same colour for the same value across plots, or similar colours for similar quantiles. If the former, format your all your data into a long dataframe and facet accordingly when plotting, the scale will be shared by default.