r - ggplot: gradient scale to diverge on specific break -


i have data

df <- data.frame(x=1:10,                  y=1:10,                  value = c(seq(from=0.5,to=3.2,length.out=9),inf)) 

which want plot gradient colour scale highlighting 3 break values:

breaks <- c(0.5,1,3.2) 

i want white colour highlight middle breaking value (that 1) , other 2 increase in intensity reach 2 tails of distribution. yet plot

require(ggplot) ggplot(df, aes(x,y,colour=value)) + geom_point(size=10) +   scale_colour_gradientn(colours = c("red","white","blue"),                          breaks = breaks, labels = format(breaks)) 

enter image description here

with white centered on mean/median value (1.85). don't understand what's point in declaring break points then.

you use scale_colour_gradient2 instead of scale_colour_gradientn:

ggplot(df, aes(x,y,colour=value)) +    geom_point(size=10) +   scale_colour_gradient2(low = "red", mid = "white", high = "blue", midpoint = 1, breaks = breaks) +   theme_bw() 

this gives:

enter image description here


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -