Reputation: 11
I am using scatterplot3d to generate several plots, and I would like to keep the scales consistent throughout each of the plots (I am trying to show changes over time, so this is essential). My current code is as follows (by no means elegant, as I am a beginner!):
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)
Is it possible to specify axis ranges to keep these consistent between plots? I have checked the vignette, but there is no information in there on this.
Thanks in advance,
Jo
Upvotes: 1
Views: 4749
Reputation: 402
You can use xlim, ylim and zlim how arguments in sccaterplot3d function, example:
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))
If you modify xlim, ylim or zlim will change the axis.
Upvotes: 1
Reputation: 1
Please use xlim
, ylim
, zlim
, the x
, y
and z
limits (min, max) of the plot.
Upvotes: -1