首页 > 解决方案 > 在 R 中使用 plot3D::scatter3D() 更改刻度标签

问题描述

我正在尝试使用scatter3D()R 中的函数制作如下图:

散点图 3D 图

到目前为止一切顺利,但我正在努力将轴上的刻度标签Variant从 1, 2, 3 更改为A, B, C。有什么方法可以实现吗?

要创建上面的图:

library(plot3D)
n = 20 # number of datapoints
y = rep(c(1,2,3), each = n) # for plotting each line
x = rep(seq(-2, 2, length.out = n),3)
z = pnorm(x)

lapply(1:3, function(index){
  add = TRUE
  if(index == 1)
    add = FALSE
  scatter3D(x = x[y == index], 
            z = z[y == index], 
            y = y[y == index], 
            type = "l", 
            phi = 20,  
            theta = -50,
            xlab = "RT1", 
            ylab = "Variant", 
            zlab = "Delta", 
            col = "red", 
            ticktype = "detailed", 
            add = add, 
            ylim = c(0,4), 
            xlim = c(-3, 3))
})

标签: rscatter3dplot3d

解决方案


推荐阅读