ktr002
ktr002

Reputation: 45

R scatterplot3d turn x axis text 45°

I have something like this, and want to turn xlabels 45 degrees (it is going to be rather long text):

a<-c(1:10)
b<-c(1:10)
c<-c(1:10)
  scatterplot3d(a,b,c,
                main="3-D Scatterplot",color="blue", pch=19,
                type="h", lty.hplot=2, box=F,
            scale.y=.5, 
            lty.grid=1,
            lab=c(9,5,1),
            xlab="",
            ylab="",
            zlab="")

Upvotes: 2

Views: 1047

Answers (1)

LyzandeR
LyzandeR

Reputation: 37879

You could do the following:

library(scatterplot3d)
a<-c(1:10)
b<-c(1:10)
c<-c(1:10)
#remove x labels using x.ticklabs = ''
scatterplot3d(a,b,c,
              main="3-D Scatterplot",color="blue", pch=19,
              type="h", lty.hplot=2, box=F,
              scale.y=.5, 
              lty.grid=1,
              lab=c(9,5,1),
              xlab="",
              ylab="",
              zlab="", x.ticklabs='')
#add the labels using the text function. srt specifies the angle.
text(x=b, y=1, pos=1, labels=b, srt=45, adj=1, xpd=TRUE, offset=0.5)

And it works!

enter image description here

Upvotes: 1

Related Questions