首页 > 解决方案 > R:plot3D scatter3D,有 coord_fixed() 选项吗?

问题描述

ggplot2我在 2D 和 3D 中使用和绘制相同的散点图plot3d。为了更好的可读性,我总是喜欢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")

图。1

图2

标签: rggplot2coordinatesscatter-plotplot3d

解决方案


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,则缩放坐标以保留纵横比


推荐阅读