Skip to content
Prev 384659 / 398525 Next

unique scale color ggplot2

Dear R users,

I want to create a plot for multiple sites and to keep the same color range
scale (the correlation values range from -0.5 to 0.7 for all data, but I
have sites with different min and max).

I used this code:
cols<-c("#0288D1", "#039BE5", "#03A9F4","#29B6F6", "#4FC3F7", "#FFCDD2",
"#E57373", "#F44336", "#E53935", "#D32F2F", "#C62828", "#B71C1C")
zCuts <-seq(-.5, 0.6, by = 0.1)
p<-ggplot(df1, aes(x=as.factor(spei), y=as.factor(month), fill = cut(cor,
zCuts))) +
  geom_tile() +
  scale_fill_manual(values=cols)

but for each site the scale color is different.


Please help me to solve this problem!

Thank you!


Bests!

Catalin