【问题标题】:Remove axes ticks using plot3d in R在 R 中使用 plot3d 删除轴刻度
【发布时间】:2020-01-03 03:23:32
【问题描述】:

我正在尝试渲染一个内部绘制有球体的 3D 立方体。 我在 R 中使用 RGL 库并使用 plot3d 进行渲染 我想保留所有 12 条轴线,但去掉刻度线。

这是我的代码:

library(rgl)

rgl.open()
rgl.bg(color='white')

a <- c(0.9, 0.9, 0.1)
b <- c(0.1, 0.9, 0.9)
c <- c(0.9, 0.1, 0.1)

xlab="z"
ylab="y"
zlab="x"
type="s"
col="red"
size=3

plot3d(a, b, c, xlab, ylab, zlab, type, col, size, xlim=c(0,1), ylim=c(0,1), zlim=c(0,1), aspect=c(3,3,3), main="", sub="", ann=FALSE, axes=TRUE)

输出:

我已尝试使用此POST 作为解决方案,但在确保立方体透明的同时无法显示轴线。

以下代码基于上述帖子:

plot3d(xvar, yvar, zvar, type = 's', col = colgroup, size = 0.05, alpha = 0.50, 
       radius = 0.2, xlab = 'Cost Leader', ylab = 'Performance Leader', 
       zlab = 'Fashion Leader', axes = FALSE)
rgl.bbox(xlen = 0, ylen = 0, zlen = 0, color = c('grey100'), alpha=0.5, axes=TRUE)
text3d(x = xvar, y = yvar, z = zvar, text = brands, adj = c(2.5,2.5), cex = 0.7)

我尝试添加 alpha 争论,但这是输出(其中之一):

感谢任何输入。这个看似简单的问题引起了相当多的头疼。

TLDR:如何制作带有标记的点和 xyz 轴的透明立方体。 (没有记号)。

R 版本:3.5.1 平台:x86_64-apple-darwin15.6.0(64位)

附:无法为 plot3d 制作新标签 .. 因此它们被拆分了...

【问题讨论】:

    标签: r plot 3d rgl


    【解决方案1】:

    这与您的问题无关,但很重要:不要使用rgl.open()rgl.bg()rgl.bbox()。他们只会给你带来麻烦。使用open3d()bg3d()bbox3d()

    同样不相关,但我认为这是个好建议:不要在没有命名参数的情况下使用具有长参数列表的函数。将未命名的 args 匹配到错误的东西太容易了。

    至于您的问题:绘制没有轴的图,然后添加您想要的非标准轴。由于您真的不想要任何东西,因此只需使用box3d() 来绘制框。例如,

    library(rgl)
    open3d()
    bg3d(color = "white")
    
    a <- c(0.9, 0.9, 0.1)
    b <- c(0.1, 0.9, 0.9)
    c <- c(0.9, 0.1, 0.1)
    
    xlab <-"z"
    ylab <- "y"
    zlab <- "x"
    type <- "s"
    col <- "red"
    size <- 10
    
    plot3d(a, b, c, 
          xlab = xlab, ylab = ylab, zlab = zlab, 
          type = type, col = col, 
          xlim = c(0,1), ylim = c(0,1), zlim = c(0,1), 
          aspect = c(3,3,3), 
          size = size,
          main = "", sub = "", ann = FALSE, axes = FALSE)
    box3d()
    

    这会产生

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-30
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多