Home > Mobile >  How to customise 3D scatter plot
How to customise 3D scatter plot

Time:11-29

Let say, I have below 3D scatter plot

library(mvtnorm)
library(threejs)
u <- seq(-5, 5, by = .1)
v <- seq(-5, 5, by = .1)
M <- expand.grid(u,v)

x <- M$Var1
y <- M$Var2
sigma <- matrix(c(1, .5, .5, 1), nrow = 2, byrow = TRUE)
z <- dmvnorm(x = M, sigma = sigma)

scatterplot3js(x, y, z, phi = 40, theta = 20,
          color=rainbow(length(z)),
          colkey = FALSE,
          cex = .3,
          main = "Bivariate Normal")

While this plot is okay, I want to change the labels x, y, and z with some custom names i.e. A 1, B 1, C 1.

Also, instead of displaying the tick marks of z axis as row, I was to add % e.g. instead of just reporting 0.18, I want to report 0.18%

Is there any way to achieve these.

Thanks for any pointer.

CodePudding user response:

axisLabels and z.ticklabs are these arguments what you are looking for? see ?scatterplot3js

scatterplot3js(x, y, z, phi = 40, theta = 20,
               color=rainbow(length(z)),
               colkey = FALSE,
               cex = .3,
               main = "Bivariate Normal",
               axisLabels=c("Axis label 1", "Axis label 2 [%]", "Axis label 3"),
               z.ticklabs = c("0.00%","0.04%", "0.07%", "0.11%", "0.15%", "0.18%"))

enter image description here

  • Related