1

In R, I am trying to plot a 3D scatter plot with the following code:

library(scatterplot3d)

mtcars$pcolor[mtcars$cyl==4] <- "red"
mtcars$pcolor[mtcars$cyl==6] <- "blue"
mtcars$pcolor[mtcars$cyl==8] <- "darkgreen"
with(mtcars, {
    s3d <- scatterplot3d(disp, wt, mpg,     
        color=pcolor, pch=19,       
        type="h", lty.hplot=2,      
        scale.y=.75,             
        main="3D",
        xlab="Displacement",
        ylab="Weight",
        zlab="Miles")
     s3d.coords <- s3d$xyz.convert(disp, wt, mpg)
     text(s3d.coords$x, s3d.coords$y,
        labels=row.names(mtcars),     
        pos=4, cex=.5)               

legend("topleft", inset=.05,      
    bty="n", cex=.5,             
    title="Number of Cylinders",
    c("4", "6", "8"), fill=c("red", "blue", "darkgreen"))
})

But now I want to break the y-axis (weight). I know there is the axis.break in the library plotrix, but how do I combine that with scatterplot3d?

Robert Wade
  • 4,918
  • 1
  • 16
  • 35
rororo
  • 815
  • 16
  • 31

1 Answers1

0

I am not sure this is possible. According to the package documentation, "some of par arguments do not apply here, e.g., many of those for axis calculation."

It might be possible by adjusting tick mark labels, as seen in this answer from the author of the Scatterplot3d package, but that doesn't move the actual points around. http://r.789695.n4.nabble.com/scatterplot3d-customise-axes-td4554528.html

Finally, I find these types of displays hard to interpret. Consider the lattice plot approach.

Todd T
  • 56
  • 3
  • Thanks. My own data looks a bit clearer and the final idea would be to lay an smoothened plane over the data. – rororo Nov 24 '17 at 15:55