creating a more continuous color palette in r, ggplot2, lattice, or latticeExtra

后端 未结 3 634
野的像风
野的像风 2020-12-17 00:02

Warning.... very novice question follows:

I am trying to plot a fairly regular distribution of several thousand (X,Y) points each associated with a value, let\'s cal

3条回答
  •  执念已碎
    2020-12-17 00:32

    Have you looked at scale_gradient in ggplot? Or scale_brewer for discrete colours? Here's an example of scale_gradient

    dat <- data.frame(x = rnorm(1000), y = rnorm(1000), z = sample(-20:20, 1000, TRUE))
    
    p <- ggplot(dat, aes(x, y, colour = z)) + geom_point() 
    p + scale_colour_gradient()
    p + scale_colour_gradient(low = "red", high = "blue")
    p + scale_colour_gradient2(low = "red", mid = "white", high = "blue")
    

提交回复
热议问题