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

后端 未结 3 628
野的像风
野的像风 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:53

    The "concept" you are missing is the at argument to levelplot() which defines the breakpoints between colour levels and/or contour lines. The default is pretty(z) which results in only a few levels. You can set at to be a sequence covering the range of values you want.

    library(latticeExtra)
    
    dat <- data.frame(x = rnorm(1000), y = rnorm(1000), z = rnorm(1000, mean = 1))
    ## for centering the colour key around zero
    maxz <- max(abs(dat$z))
    
    levelplot(z ~ x * y, dat, at = seq(-maxz, maxz, length = 100), 
        panel = panel.levelplot.points, par.settings = custom.theme.2())
    

提交回复
热议问题