color gradient R

5

How do I change the color of the graph in a gradient way with the variable years, starting from white to intense red.

colourCount = length(unique(tabela.estacao$ano))
getPalette = colorRampPalette(brewer.pal(9,"Reds"))

ggplot(tabela.estacao, aes(x=mes, y=tempMedia, group=as.factor(ano) )) +
geom_smooth(aes(colour = ano)) + ggtitle(est) + scale_fill_manual(name="Min-Max-Range and Mean \nof specific Croptypes",
values=getPalette(colourCount))
scale_x_discrete(limits=c("janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"))
theme(axis.text.x = element_text(angle = 90, hjust = 1))

    
asked by anonymous 13.10.2016 / 15:00

1 answer

2

You can add a call to the scale_colour_continous function.

For example:

library(ggplot2)
dados <- data.frame(x = runif(100), y = runif(100), ano = rep(2010:2014, each = 20))
ggplot(dados, aes(x = x, y = y, group = as.factor(ano))) +
  geom_smooth(aes(colour = ano)) +
  scale_colour_continuous(low = "white", high = "red")

    
13.10.2016 / 17:04