[R] help working with persp plot function

Andrew Robinson andrewr at uidaho.edu
Mon Oct 4 00:23:02 CEST 2004


Hi Steve,

persp() is looking for x and y to be the coordinates on the axes
rather than corresponding directly to the points. So, something like

x <- c(1:3)
y <- c(1:3)

z <- c(1:9)

Take a look at the third example in help(persp) to clarify.

For your data you might try the surface() function in the fields
package - see .e.g

http://www.cgd.ucar.edu/stats/Software/Fields/fields.demo.shtml

Good luck!

Andrew

On Sun, Oct 03, 2004 at 06:08:57PM -0400, Steven K Friedman wrote:
> 
> Hi, 
> 
> I don't understand why this is not working.  Help is appreciated. 
> 
> I need to plot the following as a surface, but persp returns an error. 
> 
> tpcp_xy[1:10,]
>   X_COORD  Y_COORD TPCP
> 1  465459.7 175924.1 0.85
> 2  466145.8 324017.3 2.30
> 3  467720.2 372143.1 1.56
> 4  470293.2 348064.8 2.87
> 5  476566.9 205501.8 0.94
> 6  477774.9 142561.0 1.31
> 7  479207.0 162919.6 3.04
> 8  480890.8 290641.3 2.20
> 9  488865.9 159201.4 2.30
> 10 490328.3 248049.0 2.81 
> 
> 
> Note that the X_COORD column is sorted in an increasing order. 
> 
> >objects(2)
> [1] "TPCP"    "X_COORD" "Y_COORD"
> >persp(X_COORD, Y_COORD, TPCP)
> Error in persp.default(X_COORD, Y_COORD, TPCP) :
>       increasing x and y values expected 
> 
> Ok so why is the function returning an error message? 
> 
> Thanks for your time and insights. 
> 
> Steve Friedman           email friedm69 at msu.edu
> Department of Forestry
> Michigan State University
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

-- 
Andrew Robinson                      Ph: 208 885 7115
Department of Forest Resources       Fa: 208 885 6226
University of Idaho                  E : andrewr at uidaho.edu
PO Box 441133                        W : http://www.uidaho.edu/~andrewr
Moscow ID 83843                      Or: http://www.biometrics.uidaho.edu
No statement above necessarily represents my employer's opinion.




More information about the R-help mailing list