R:plot3D scatter3D,有coord_fixed()选项吗?

时间:2019-02-22 03:12:53

标签: r 3d coordinates scatter

我正在使用ggplot2plot3d在2D和3D中进行相同的散点图。我总是喜欢尽可能地在coord_fixed()散点图中进行ggplot2,以提高可读性。有没有办法在scatter3D图中执行相同的操作?谢谢

MWE:

data(iris)
head(iris)
library(ggplot2)
ggplot(iris, aes(x=Petal.Length, y=Petal.Width)) +
    geom_point(pch=16) + theme_light() + coord_fixed()
library(plot3D)
scatter3D(iris$Petal.Length, iris$Sepal.Length, iris$Petal.Width, bty = "u", pch = 16, alpha = 0.5,
          xlab = "Petal.Length", ylab = "Sepal.Length", zlab = "Petal.Width", phi = 0, theta = 40,
          col.panel = "white", col.grid = "gray", col="black", ticktype = "detailed")

fig1

fig2

1 个答案:

答案 0 :(得分:2)

scale = FALSE执行此操作:

scatter3D(iris$Petal.Length, iris$Sepal.Length, iris$Petal.Width, bty = "u", pch = 16, alpha = 0.5,
          xlab = "Petal.Length", ylab = "Sepal.Length", zlab = "Petal.Width", phi = 0, theta = 40,
          col.panel = "white", col.grid = "gray", col="black", ticktype = "detailed",
          scale = FALSE)

来自?persp

  

如果scale为TRUE,则分别转换x,y和z坐标。如果scale为FALSE,则会缩放坐标,以便保留宽高比