-4

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) 

How to make labels to the axes with curve3d in R? And how I can rotate this plot?

Cath
  • 23,906
  • 5
  • 52
  • 86
TobiR
  • 207
  • 3
  • 11
  • 1
    Please provide the code you have written and a working data example. You can get the latter easily by pasting the output of `dput(yourdata)`. – LAP Nov 16 '16 at 08:06
  • 1
    Note that your question title is worth an automatic downvote. Everyone asking a question needs help. – Roland Nov 16 '16 at 08:17
  • 1
    `curve3d` from `emdbook` does have parameters `xlab`, `ylab`, `zlab` that you can use to label the axes and probably you can use additionnal parameters ("symbolised" by `...`) to define the rotation you want. Have you taken a look at `?curve3d` ? this could be a good start. – Cath Nov 16 '16 at 08:39
  • Thank you so much, Cath :) Can you help with rotation,how i can define that? – TobiR Nov 16 '16 at 08:52

1 Answers1

0

You need to read ?curve3d (always start with the help page of a function when you try to do something with it).

The first part tells you about the Usage of the function, where you can see 3 parameters that can help you for the first part of your question: xlab, ylab and zlab. You need to know exactly how they work and if that's really what you need. For that, go straight to the second paragraph.

The second part is Arguments and details the function parameters. So you get reassured that indeed xlab, ylab and zlab are what you need but you still have no clue about the rotation. You read carefully till the last "argument" which is ...: additional arguments to the plotting functions. That's promising, the rotation arguments must be there. Problem is, what are the "plotting functions" ?
To know that, you need to go back to the sys3d argument : 3D plotting system to use. You're not defining it so it takes the default one, which, as you can see in the Usage section, is persp.

Probably you don't know how persp works and how you can define angles to rotate your plot so, there you go again: ?persp. I'm not gonna detail the help page as the structure is the same as ?curve3d and actually as any help page. So, reading the help page of persp, you find 2 interesting parameters: theta and phi, which are the angles defining the viewing direction. theta gives the azimuthal direction and phi the colatitude.
There you go !

Let's give it a try:

curve3d(87.56 + 0.772*x - 0.022*x*y + 0.162*x^2, 
        xlab="axe 1", ylab="axe 2", zlab="axe 3", 
        theta=10, phi=45)

enter image description here

Cath
  • 23,906
  • 5
  • 52
  • 86