I need to change the colors of the scale of a ggplot in R. My table is:
tt<-data.frame(C1=c(0.4,.5,.5, 0, .8,.8),C2=c(.5,.6,.7, 0, .7,.8), C3=c(.8,.7,.9, 0, .8,.7),
C4=c(rep(0,6)), C5=c(0.4,.6,.6, 0, .8,.8),C6=c(0.8,.7,.5, 0, .8,.8), C7=c(0.8,.6,.4, 0, .8,.8))
row.names(tt)<-paste("F", 1:6, sep='')
tt<-as.matrix(tt)
Then I do the reshape:
library(ggplot2)
library(reshape2)
tt_melt <- melt(tt)
tt_melt
colnames(tt_melt)<-c('fila', 'columna', 'performance')
And my graph is a representation of a call center and a metric related to each position:
ggplot(data=tt_melt,
aes(x=columna, y=fila, fill=performance)) + geom_tile() +
geom_text(aes(label=performance), color='white')
+ theme_minimal(base_size = 12, base_family = "")+
labs(title = 'Performance por posicion en el call')+
scale_colour_manual(values = c("red","yellow", "green"))
scale_fill_gradient(low = "yellow", high = "darkgreen")
But it doesn't take the scale. I need to get the 0s in white (because it means that there's nobody in that space) and the rest from red to green. So it's not a truly continuous scale (but should be continuous from red to green). How can I make ggplot take the scale? Also, how can I create a scale that has a condition over the values? And finally, if there's a better way to do this I would be glad to hear about it. Many thanks.