【问题标题】:remove panel outline / add axis ticks and colour scale outline in lattice wireframe plots在格线框图中删除面板轮廓/添加轴刻度和色标轮廓
【发布时间】:2015-11-02 10:35:20
【问题描述】:

我有一系列的线图,类似于下面的例子;

require(lattice)

# set up some data
theta <- seq(-3, 3, .4)
data <- expand.grid(theta, theta)
data$z <- dnorm(data[,1]) * dnorm(data[,2])
names(data) <- c('x','y','z')

# plot it
wireframe(z ~ x * y, data,
          scales = list( arrows = FALSE),
          aspect = c(1, .6),
          drape = TRUE)

这给出了下面的情节。

我想删除面板轮廓。标准解决方案是使用par.settings = list(axis.line = list(col = 'transparent'));

# try to remove outline
wireframe(z ~ x * y, data,
          scales = list( arrows = FALSE),
          aspect = c(1, .6),
          drape = TRUE,
          par.settings = list(axis.line = list(col = 'transparent')))

这确实删除了轮廓,但并不止于此......

轴刻度线以及色标周围的轮廓也被删除。解决方案可用于 2d 绘图,例如参见 Controlling axis ticks and axis lines separately on R lattice xyplot ,但我一直无法为 3d/线框绘图找到类似的解决方案。

我已经尝试根据上述答案摆弄提供轴函数,但似乎该函数仅被调用顶部/底部/左侧/右侧,这对于 3d 绘图不是很有用。

问题;

设置par.settings = list(axis.line = list(col = 'transparent'))时如何阻止lattice移除刻度线和刻度轮廓?

如果做不到这一点,线框图上的刻度线使用什么函数,色标上的轮廓线使用什么函数?

【问题讨论】:

    标签: r data-visualization


    【解决方案1】:

    此代码将完成这项工作。

    wireframe(z ~ x * y, data,
              scales = list( arrows = FALSE, col="black"), # col="black" is required 
              aspect = c(1, .6),
              drape = TRUE,
              par.settings = list(axis.line = list(col = 'transparent'))
    )
    

    本文改编自Seth W Bigelow's answer

    【讨论】:

    • 啊,太简单了——不敢相信我错过了。谢谢!
    • 还需要为colorkey的轮廓添加特定的颜色; colorkey = list(height = .8, axis.line = list(col = 'black')),这不是问题的一部分,而是我的问题的一部分。
    猜你喜欢
    • 2021-04-07
    • 2011-08-18
    • 1970-01-01
    • 2020-06-14
    • 2018-03-18
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    相关资源
    最近更新 更多