I'm trying to create a color ramp to plot in ggplot2 which is dependent on factors and numbers. I'll like the color ramp to be positive above and below. In my case I want to look at dominant gender population for each point.
##Create dataframe
DF1 <- data.frame(A=c("Female","Male","Male","Female","Male","Male"),
B=c(0.2,0.5,0.4,0.8,0.1,0.5), X <- c(1,2,3,4,5,6), Y <- c(1,4,3,2,3,1))
colnames(DF1)<-c("Sex", "Ratio", "X", "Y")
A sample plot of the data using ggplot just coloured it categorically not with a colour ramp.
##Basic plot using ggplot2
ggplot() + geom_point(data=DF1, aes(X,Y,colour=A),fill=B,alpha=0.8)
I'll like to create a colour ramp which is positive both sides of zero with one side is red and the other is blue based on "Sex". The colour intensity will be dependent on the "Ratio". What is the best way to do this please?




