使用 scatterplot3d 自定义刻度和标签

Customize ticks and lables using scatterplot3d

我的目标是在我的 y 轴上绘制 9 个名字(字母“a”到“i”一个接一个)。

但是,在程序 R 中使用函数 scatterplot3d 只能绘制每隔一个字母。你知道我如何解决这个问题吗?

此致

plot_how <- scatterplot3d(Test.df,
              color = "pink",
              main="test experiment",
              xlab = "time",
              ylab = "samples ",
              zlab = "output", type = "l", box = F,
              ylim = c(1,9),
              zlim = c(0, 3000), 
              grid = F, 
              yaxt = "n",  
              scale.y = 1, 
              label.tick.marks = T, 
              y.ticklabs = c("a", "b", "c", "d", "e", "f", "g", "h", "i"))

你必须在 scatterplot3d 中使用命令 lab。如果您将命令设置为例如因为 9 个字母设置 lab = c(9,9,9) 取决于您的轴。我会给你一个样本数据的例子。

Test.df <- data.frame(letter = c("a", "b", "c", "d", "e", "f", "g", "h", "i"),
                        x = c(1, 2, 3, 4, 5, 6 , 7, 8, 9),
                        z = c(1, 2, 3, 4, 5, 6 , 7, 8, 9))

Test.df数据:

  letter x z
1      a 1 1
2      b 2 2
3      c 3 3
4      d 4 4
5      e 5 5
6      f 6 6
7      g 7 7
8      h 8 8
9      i 9 9

您可以使用此代码:

library(scatterplot3d)
  plot_how <- scatterplot3d(Test.df,
                            color = "pink",
                            main="test experiment",
                            xlab = "time",
                            ylab = "samples ",
                            zlab = "output", type = "l", box = F,
                            ylim = c(1,9),
                            zlim = c(0, 9), 
                            grid = F, 
                            yaxt = "n",  
                            scale.y = 1, 
                            label.tick.marks = T, 
                            y.ticklabs = c("a", "b", "c", "d", "e", "f", "g", "h", "i"),
                            lab = c(9,9,9))

输出图:

正如您在图中看到的,所有字母现在都在轴上。