Search code examples
r3daxis-labelsrgl

R/rgl - How to move 3d axis labels?


(I am using rgl.) I am would like to move the axis labels in the following:

plot3d(1,2,3, xlab="x", ylab="y", zlab="z", xlim=c(-4,4), ylim=c(-4,4), zlim=c(-4,4))
abclines3d(x = matrix(0, ncol=3), a = diag(3), col="black", lwd=3)

To the positions shown:

Red arrows showing that I want the labels next to the positive x,y,and z axes

Basically, I'd like the labels to be at the "ends" of the positive x, y, and z axes. How do I do this?


Solution

  • You could try something like this:

    plot3d(1,2,3, xlab="", ylab="", zlab="", xlim=c(-4,4), ylim=c(-4,4), zlim=c(-4,4))
    abclines3d(x = matrix(0, ncol=3), a = diag(3), col="black", lwd=3)
    text3d(matrix(c(3,0.2,0.2,4,-6,4,0.1,0.1,3),ncol=3),texts=c('y', 'x', 'z'))
    

    enter image description here