我想知道是否可以在scatterplot3d中指定轴标签的方向?我希望y轴标签(wt)与y轴平行,而不是像现在那样与z轴平行:
library(scatterplot3d)
with(mtcars, {
scatterplot3d(disp, wt, mpg, main="")
})

发布于 2014-08-23 14:14:38
目前,它是硬编码的。您可以创建一个新的scatterplot3d函数,并将mtext2函数定义替换为一个稍作修改的版本,该版本将接受一个'las‘参数,然后为'ylab’的该函数调用一个不同的值(2)。
......
mytext2 <- function(lab, side, line, at, las=0) mtext(lab, side = side,
line = line, at = at, col = col.lab, cex = cex.lab,
font = font.axis, las = las) # shift hard coding to a default value
lines(c(x.min, x.max), c(z.min, z.min), col = col.axis,
lty = lty.axis)
mytext2(xlab, 1, line = 1.5, at = mean(x.range))
lines(xx[1] + c(0, y.max * yx.f), c(z.min, y.max * yz.f +
z.min), col = col.axis, lty = lty.axis)
mytext2(ylab, if (angle.1)
2
else 4, las=2, line = 0.5, at = z.min + y.max * yz.f) # 2nd change
.....

发布于 2014-08-23 14:12:03
这个答案是从@JorisMeys answer to a similar question about changing the label position窃取并略微调整的。
with(mtcars, {
scatterplot3d(disp, wt, mpg, main="", ylab="")
})
dims <- par("usr")
x <- dims[1]+ 0.97*diff(dims[1:2])
y <- dims[3]+ 0.4*diff(dims[3:4])
text(x, y, "wt", srt=0)

当然,你还可以做更多的事情,特别是在利润率方面。例如:
with(mtcars, {
scatterplot3d(disp, wt, mpg, main="", ylab="",
y.margin.add=0.5)
})
dims <- par("usr")
x <- dims[1]+ 0.97*diff(dims[1:2])
y <- dims[3]+ 0.4*diff(dims[3:4])
text(x, y, "wt")

https://stackoverflow.com/questions/25458652
复制相似问题