1

这是我的代码和相关的变量结构。

Correlation_Plot = contourplot(cor_Warra_SF_SST_JJA, region=TRUE, at=seq(-0.8, 0.8, 0.2), 
labels=FALSE, row.values=(lon_sst), column.values=lat_sst,
xlab='longitude', ylab='latitude')

Correlation_Plot = Correlation_Plot + layer({ ok <- (cor_Warra_SF_SST_JJA>0.6);
            panel.text(cor_Warra_SF_SST_JJA[ok]) })
Correlation_Plot

     # this is the longitude (from -179.5 to 179.5) , 360 data in total
    > str(lon_sst) 
     num [1:360(1d)] -180 -178 -178 -176 -176 ...

     # this is the latitude (from -89.5 to 89.5), 180 data in total 
    > str(lat_sst) 
     num [1:180(1d)] -89.5 -88.5 -87.5 -86.5 -85.5 -84.5 -83.5 -82.5 -81.5 -80.5 ...

     # This is data set corresponding to longitude and latitude  
     > dim(cor_Warra_SF_SST_JJA) 
       [1] 360 180

在此处输入图像描述

我尝试使用layer()仅显示大于 0.6 的轮廓的标签,但它不起作用。

  1. 是否可以增加图例中的颜色对比度,以便真正清楚什么颜色对应什么级别。什么是颜色选项,我找不到它们?

  2. 最重要的是我想为指定的轮廓间隔(例如 +/- 0.2)画一条更粗的黑线?我认为我也可以这样做layer(),但我不确定我panel应该使用什么功能。

  3. 另外,我试图用纯色填充大陆,但我找不到任何东西。我试过使用地图,但它不适用于格子。

谢谢你的帮助。

4

2 回答 2

5

查看. ?panel.levelplot_contourplot

  1. 您可以使用该col.regions参数,该参数将采用您希望与您的间隔对应的颜色矢量,或颜色渐变函数(例如下面)。

  2. 使用自定义面板功能,类似这样(使用使用Santiago Beguería 博客上给出的方法生成的空间自相关虚拟数据集)。用于lpolygon绘制地图对象:

    生成虚拟数据集:

    library(gstat)
    
    # create structure
    xy <- expand.grid(1:360, 1:180)
    names(xy) <- c('x','y')
    
    # define the gstat object (spatial model)
    g.dummy <- gstat(formula=z~1, locations=~x+y, dummy=T, beta=1,    
      model=vgm(psill=0.025,model='Exp',range=5), nmax=20)
    
    # make a simulations based on the gstat object
    yy <- predict(g.dummy, newdata=xy, nsim=1)
    gridded(yy) = ~x+y
    
    # scale to range [-1, 1]
    z <- matrix(yy@data[, 1], ncol=180)
    z.scalefac <- (max(z) - min(z)) / 2
    z <- -1 + (z - min(z)) / z.scalefac
    
  3. 阴谋:

    library(lattice)
    library(maps)
    
    lon_sst <- seq(-179.5, 179.5, 1)
    lat_sst <- seq(-89.5, 89.5, 1)
    
    colramp <- colorRampPalette(c('red', 'yellow', 'white', 'green', 'blue'))
    
    contourplot(z, xlim=c(100, 160), ylim=c(-80, -50), 
      at=seq(-1, 1, 0.2), region=TRUE, col.regions=colramp,
      row.values=lon_sst, column.values=lat_sst, labels=FALSE, 
      xlab='longitude', ylab='latitude',
      panel = function(at, region, ...) {
        panel.contourplot(at=at, region=TRUE,  ...)
        panel.contourplot(at=c(-0.2, 0.2), lwd=2, region=FALSE, ...)
        mp <- map("world", "antarctica", plot = FALSE, fill=TRUE)
        lpolygon(mp$x, mp$y, fill=TRUE, col='gray')
    })
    

示例输出

于 2012-02-09T04:03:31.650 回答
1

Q1:您需要使用llinespanel.lines使用与上一个问题中用于大陆轮廓的相同数据来执行此操作

Q2:

?panel.contour

.... 其中说“lwd”是一个可用选项,我怀疑你会使向量的第七个元素= 2。

Q3:可能是一个填充论点,但必须指出的是,您通过不包含指向数据和您的数据准备的链接,严重阻碍了我们测试解决方案的努力。

于 2012-02-09T02:40:25.607 回答