Plotting 3d data?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Plotting 3d data?

Wesley Tansey
Hi all!

 

I'm very new to R, and I'm having trouble figuring out how to go from a file
of points that I have to a 3d surface plot of the data. I typically have
something like this:

 

X          Y          Z

0.005    0.023    34.45

0.0035  0.63      28.48

.

 

I've tried looking at the persp and wireframe packages, and the rgl package,
but I can't seem to figure out how to use any of them. I tried to take the
rgl.surface3d example and use it for myself, and this is what I have so far:

 

setwd(".")

 

data <- read.csv("data.csv",header=T)

 

x <- data$X

y <- data$Y

z <- data$Z

 

open3d()

surface3d(x, y, z)

 

That gives me the following error:

 

Error in rgl.surface(x = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  :

  y length != x rows * z cols

 

I have no idea what it is trying to tell me there. Would anyone mind helping
me out?

 

 

Wesley

 


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting 3d data?

Henrique Dallazuanna
Try scatterplot3d function in the package with same name.

On Mon, Jun 16, 2008 at 2:32 PM, Wesley Tansey <[hidden email]> wrote:

> Hi all!
>
>
>
> I'm very new to R, and I'm having trouble figuring out how to go from a
> file
> of points that I have to a 3d surface plot of the data. I typically have
> something like this:
>
>
>
> X          Y          Z
>
> 0.005    0.023    34.45
>
> 0.0035  0.63      28.48
>
> .
>
>
>
> I've tried looking at the persp and wireframe packages, and the rgl
> package,
> but I can't seem to figure out how to use any of them. I tried to take the
> rgl.surface3d example and use it for myself, and this is what I have so
> far:
>
>
>
> setwd(".")
>
>
>
> data <- read.csv("data.csv",header=T)
>
>
>
> x <- data$X
>
> y <- data$Y
>
> z <- data$Z
>
>
>
> open3d()
>
> surface3d(x, y, z)
>
>
>
> That gives me the following error:
>
>
>
> Error in rgl.surface(x = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  :
>
>  y length != x rows * z cols
>
>
>
> I have no idea what it is trying to tell me there. Would anyone mind
> helping
> me out?
>
>
>
>
>
> Wesley
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> 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.
>


--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting 3d data?

Duncan Murdoch
In reply to this post by Wesley Tansey
On 6/16/2008 1:32 PM, Wesley Tansey wrote:

> Hi all!
>
>  
>
> I'm very new to R, and I'm having trouble figuring out how to go from a file
> of points that I have to a 3d surface plot of the data. I typically have
> something like this:
>
>  
>
> X          Y          Z
>
> 0.005    0.023    34.45
>
> 0.0035  0.63      28.48
>
> .
>
>  
>
> I've tried looking at the persp and wireframe packages, and the rgl package,
> but I can't seem to figure out how to use any of them. I tried to take the
> rgl.surface3d example and use it for myself, and this is what I have so far:
>
>  
>
> setwd(".")
>
>  
>
> data <- read.csv("data.csv",header=T)
>
>  
>
> x <- data$X
>
> y <- data$Y
>
> z <- data$Z
>
>  
>
> open3d()
>
> surface3d(x, y, z)
>
>  
>
> That gives me the following error:
>
>  
>
> Error in rgl.surface(x = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  :
>
>   y length != x rows * z cols
>
>  
>
> I have no idea what it is trying to tell me there. Would anyone mind helping
> me out?

surface3d (and rgl.surface) expect you to have data that corresponds to
a grid defining the surface.  So you need at least one of the parameters
(z in surface3d, y in rgl.surface) to be a matrix with rows
corresponding to x values and columns corresponding to the other variable.

If your data is really a bunch of points, not on a grid, then you need
to use plot3d() to plot it as points, or convert it to a surface.  The
interp() function in the akima package can do that.  (There are lots of
other possibilities too.)

Duncan Murdoch

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting 3d data?

Wesley Tansey

> If your data is really a bunch of points, not on a grid, then you need
> to use plot3d() to plot it as points, or convert it to a surface.  The
> interp() function in the akima package can do that.  (There are lots of
> other possibilities too.)


Actually, my data is on a grid. The values are something like 0 < x < y <
0.05, with a 0.00005 step for both x and y. I tried using interp() as
follows:

data <- ..

x <- data$X

y <- data$Y

z <- data$Z

temp <- interp(x, y, z)

plot.new()
image(temp, add=TRUE)


I figured showing an image would just verify that the grid was formed
correctly, but that didn't seem to work.


Wesley

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting 3d data?

Duncan Murdoch
On 16/06/2008 4:57 PM, Wesley Tansey wrote:

>> If your data is really a bunch of points, not on a grid, then you need
>> to use plot3d() to plot it as points, or convert it to a surface.  The
>> interp() function in the akima package can do that.  (There are lots of
>> other possibilities too.)
>
>
> Actually, my data is on a grid. The values are something like 0 < x < y <
> 0.05, with a 0.00005 step for both x and y. I tried using interp() as
> follows:
>
> data <- ..
>
> x <- data$X
>
> y <- data$Y
>
> z <- data$Z
>
> temp <- interp(x, y, z)
>
> plot.new()
> image(temp, add=TRUE)

Normally you would not use plot.new(), and you would skip add=TRUE.  Let
image work out the scale of the plot.  (add=TRUE tells it to use the
existing scale, among other things.)

Duncan Murdoch

>
>
> I figured showing an image would just verify that the grid was formed
> correctly, but that didn't seem to work.
>
>
> Wesley
>
> ______________________________________________
> [hidden email] mailing list
> 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.

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Differential Equations

David Arnold
All,

I've found odesolve and lsoda.

Any other packages for differential equations?

Any good tutorials on using R and solving differential and partial  
differential equations?

D.

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Differential Equations

Peng Jiang
hi , David.

I think odesolve is what you need , do you ever try it ?
Solving differential equations is not a strong function of R, that  
means,
maybe you should try to write your own procedure using your own  
numerical
method for your own specific equation .

regards.

On 2008-6-18, at 上午9:25, David Arnold wrote:

> All,
>
> I've found odesolve and lsoda.
>
> Any other packages for differential equations?
>
> Any good tutorials on using R and solving differential and partial  
> differential equations?
>
> D.
>
> ______________________________________________
> [hidden email] mailing list
> 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.











--------------------------
Peng Jiang
江鹏
Ph.D. Candidate

Antai College of Economics & Management
安泰经济管理学院
Department of Mathematics
数学系
Shanghai Jiaotong University (Minhang Campus)
800 Dongchuan Road
200240 Shanghai
P. R. China

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Differential Equations

Michael Lawrence
In reply to this post by David Arnold
On Tue, Jun 17, 2008 at 6:25 PM, David Arnold <[hidden email]>
wrote:

> All,
>
> I've found odesolve and lsoda.
>
> Any other packages for differential equations?
>

There's Rsundials, which gives you an algebraic ode solver.


>
> Any good tutorials on using R and solving differential and partial
> differential equations?
>
> D.
>
> ______________________________________________
> [hidden email] mailing list
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Differential Equations

Spencer Graves
      I just got 37 hits from RSiteSearch('differential equation',
'fun') including odesolv{fda}, rk4{deSolve}, rk4{odesolve}, in addition
to lsoda{odesolve} and the Rsundials package.

      hope this helps.
      Spencer Graves

Michael Lawrence wrote:

> On Tue, Jun 17, 2008 at 6:25 PM, David Arnold <[hidden email]>
> wrote:
>
>  
>> All,
>>
>> I've found odesolve and lsoda.
>>
>> Any other packages for differential equations?
>>
>>    
>
> There's Rsundials, which gives you an algebraic ode solver.
>
>
>  
>> Any good tutorials on using R and solving differential and partial
>> differential equations?
>>
>> D.
>>
>> ______________________________________________
>> [hidden email] mailing list
>> 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.
>>
>>    
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> 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.
>
>

______________________________________________
[hidden email] mailing list
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.