【问题标题】:scatterplot3d - change axis rangescatterplot3d - 更改轴范围
【发布时间】:2015-07-21 14:14:30
【问题描述】:

我正在使用 scatterplot3d 生成多个绘图,并且我希望在每个绘图中保持比例一致(我试图显示随时间的变化,所以这是必不可少的)。我当前的代码如下(绝不优雅,因为我是初学者!):

library(scatterplot3d)
file<-read.csv("DAY2.csv")
axis1<-file$axis1
axis2<-file$axis2
axis3<-file$axis3
s3d <- scatterplot3d(axis1, axis2, axis3)
colors <- c("#9900FF", "#E69F00", "#339900", "#0000FF")
colors <- colors[as.numeric(file$treatment)]
s3d <- scatterplot3d(file[,1:3], pch = 16, color=colors, xlab =
"Axis 1", ylab = "Axis 2", zlab = "Axis 3")
legend(s3d$xyz.convert(0.4, 0.4, -0.1), col= c("#9900FF", "#E69F00", 
"#339900", "#0000FF"), bg="white", lty=c(1,1), lwd=2, yjust=0,      
legend = c("high perf", "low perf"), cex = 0.7)

是否可以指定坐标轴范围以保持绘图之间的一致性?我已经检查了小插图,但里面没有这方面的信息。

提前致谢,

【问题讨论】:

    标签: r plot


    【解决方案1】:

    您可以在 sccaterplot3d 函数中使用 xlim、ylim 和 zlim 如何参数,例如:

    library(scatterplot3d)
    x <- c(1, 2, 3)
    y <- c(2, 2, 2)
    z <- c(6, 7, 8)
    max_x <- max(x)
    min_x <- min(x)
    max_y <- max(y)
    min_y <- min(y)
    max_z <- max(z)
    min_z <- min(z)
    s3d <- scatterplot3d(x,y,z, pch=6, angle=45, color="red",
            xlim=c(min_x,max_x),
            ylim=c(min_y,max_y),
            zlim=c(min_z,max_z))
    

    如果修改 xlim,ylim 或 zlim 会改变轴。

    【讨论】:

      【解决方案2】:

      请使用图的xlimylimzlimxyz 限制(最小值、最大值)。

      【讨论】:

        猜你喜欢
        • 2022-01-24
        • 2021-10-29
        • 2018-03-19
        • 1970-01-01
        • 1970-01-01
        • 2017-08-02
        • 2015-09-14
        • 2016-02-26
        • 1970-01-01
        相关资源
        最近更新 更多