简体   繁体   English

使用 scatterplot3d 自定义刻度和标签

[英]Customize ticks and lables using scatterplot3d

My goal is to plot 9 names on my y axis (the letter "a" to "i" by one letter after another).我的目标是 plot 我的 y 轴上的 9 个名字(字母“a”到“i”一个接一个)。

However only every second letter is being plotted using the function scatterplot3d in the program R. Do you know how I could solve this problem?但是,在程序 R 中,使用 function scatterplot3d 仅每隔一个字母绘制一次。你知道我如何解决这个问题吗?

Sincerely真挚地

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"))

You have to use the command lab in scatterplot3d.您必须在 scatterplot3d 中使用命令lab If you set the command to for example because of 9 letters set lab = c(9,9,9) depending on your axis.例如,如果您将命令设置为因为有 9 个字母,则根据您的轴设置lab = c(9,9,9) I will give you an example with a sample data.我会给你一个样本数据的例子。

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 data:测试.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

You can use this code:您可以使用此代码:

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))

Output plot: Output plot:

在此处输入图像描述

As you can see in the plot, all the letters are now on the axis.正如您在 plot 中看到的,所有字母现在都在轴上。

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

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