Rolma Rolma - 22 days ago 6
R Question

How can I add axis scale in R?

I have some problem with curve3d.
I have a following equation to be plotted:

library(emdbook)
curve3d ( 87.56 + 0.772*x - 0.022*x*y + 0.162*x^2, xlim=c(0,70), ylim=c(0,70), xlab="axe1", ylab="axe2", zlab="axe3", col="green", phi = 10, theta = 180)


How i can add scale to axes?

Answer

By scale you mean ticks, I guess?

emdbook::curve3d() uses graphics::persp() as a default to plot. To add ticks you can change the persp() parameter ticktype from "simple" to "detailed". See ?persp for even more options.

library(emdbook)
curve3d ( 
  87.56 + 0.772*x - 0.022*x*y + 0.162*x^2, 
  xlim=c(0,70), ylim=c(0,70), 
  xlab="axe1", ylab="axe2", zlab="axe3", 
  col="green", 
  phi = 10, theta = 180,
  sys3d = "persp",
  ticktype = "detailed"
)

enter image description here

By the way I would consider using sys3d = "rgl" to get a real, movable 3D plot. rgl is a powerful 3D plotting package.