简体   繁体   English

Rwireframe()使用格子错误的颜色条

[英]R wireframe() wrong colorbar using lattice

I try to plot a transect using wireframe() with lattice 我尝试绘制样使用wireframe()lattice

the colorbar is wrong 彩条错误

  require(marmap)
  require(lattice) 

     Bathy2 <- getNOAA.bathy(lon1 = 30, lon2 = 47,
                               lat1 = -12, lat2 = -28, resolution = 2)
#plot of the area + transect
     plot(Bathy2, image=TRUE, land = TRUE, lwd = 0.03,
             bpal = list(c(0,max(Bathy2), greys), c(min(Bathy2), 0, blues)))
     belt3 <- get.box(Bathy2, x1 = 34, x2 = 46, y1 = -20, y2 =  -20, width = 3, col = "red")

#3Dplot of the transect
       wireframe(belt3, shade = T, zoom = 1.1,
                  aspect = c(1/4, 0.1),
                  screen = list(z = -60, x = -55),
                  par.settings = list(axis.line = list(col = "white")),
                  par.box = c(col =rgb(0, 0, 0, 0.1)),
                  xlab="", colorkey = TRUE)

what I obtain is a pink colorbar 我得到的是粉红色的彩条 在此处输入图片说明

As explained here , with shade = TRUE : 如此处所述 ,使用shade = TRUE

the SAME Z-VALUE CAN HAVE DIFFERENT COLORS depending on the orientation of the facet with respect to the viewing direction and the light source. 根据小平面相对于观察方向和光源的方向,相同的Z值可能具有不同的颜色。 So, a colorkey DOES NOT MAKE SENSE. 因此,色键不起作用。

So I suggest using drape = TRUE instead: 所以我建议改用drape = TRUE

# 3Dplot of the transect
wireframe(belt3, drape = TRUE, zoom = 1.1,
          aspect = c(1/4, 0.1),
          screen = list(z = -60, x = -55),
          par.settings = list(axis.line = list(col = "white")),
          par.box = c(col =rgb(0, 0, 0, 0.1)),
          xlab="", colorkey = TRUE, lwd = 0.2)

在此处输入图片说明

You can also define your own color palette. 您也可以定义自己的调色板。 Just check ?wireframe . 只需检查?wireframe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM