[R] 3D surface plot

Duncan Murdoch murdoch.duncan at gmail.com
Wed May 4 02:10:32 CEST 2016


On 30/04/2016 1:48 PM, T.Riedle wrote:
> Dear R users,
>
> I am trying to generate a 3D surface plot given the inflator formula in the attached file.
>
> Now, I want to create a 3D plot showing how Delta changes with the values of Abs(B) and sigma. The other variables in the formula are constant. Delta is calculated daily therefore the subscript t which denotes the day. I have used different functions and different packages but I get either wrong results or an error in R.
>
> Does anyone have an idea which function I should use?

One way is to create a function of two arguments, e.g.

f <- function(x, y) x^2 + y^2

This function needs to be "vectorized", i.e. if x and y are vectors, it 
needs to pair the values and produce a vector as an answer.  Then

library(rgl)
persp3d(f)

will do a perspective plot of it.  There are a lot of optional arguments 
to set the range of x, y, labels, colours, etc.

Duncan Murdoch

>
> Furthermore, I think I have to create a matrix using the formula above but I do not know how to do that in this connection. Can any body help me with the code for this purpose?
>
> Thanks a lot in advance.
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list