Description Usage Arguments Details Value See Also Examples

Reformats the vector from evaluating a function on a grid of points into a list for use with surface plotting function. The list has the usual components x,y and z and is suitable for use with persp, contour, image and image.plot.

1 | ```
as.surface(obj, z, order.variables="xy")
``` |

`obj` |
A description of the grid used to evaluate the function. This can either be in the form of a grid.list ( see help file for grid.list) or the matrix of grid of points produced by make.surface.grid. In the later case obj is a matrix with the grid.list as an attribute. |

`z` |
The value of the function evaluated at the gridded points. |

`order.variables` |
Either "xy" or "yx" specifies how the x and y variables used to evaluate the function are matched with the x and y grids in the surface object. |

This function was written to simply to go back and forth between a matrix of gridded values and the stacked vector obtained by stacking columns. The main application is evaluating a function at each grid point and then reforming the results for plotting. (See example below.)

If zimage is matrix of values then the input vector is c( zimage). To go from the stacked vector to the matrix one needs the the nrow ncol and explains why grid information must also be specified.

Note that the z input argument must be in the order values in order of stacking columns of the image. This is also the order of the grid points generated by make.surface.grid.

To convert irregular 2-d data to a surface object where there are missing cells see the function as.image.

A list of class surface. This object is a modest generalization of the list input format (x,y,z,) for the S functions contour, image or persp.

`x` |
The grid values in the X-axis |

`y` |
The grid values in the Y-axis |

`z` |
A matrix of dimensions nrow= length of x and ncol= length of y with entries being the grid point value reformatted from z. |

grid.list, make.surface.grid, surface, contour, image.plot, as.image

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
# Make a perspective of the surface Z= X**2 -Y**2
# Do this by evaluating quadratic function on a 25 X 25 grid
grid.l<-list( abcissa= seq( -2,2,,15), ordinate= seq( -2,2,,20))
xg<-make.surface.grid( grid.l)
# xg is a 300X2 matrix that has all pairs of X and Y grid values
z<- xg[,1]**2 - xg[,2]**2
# now fold z in the matrix format needed for persp
out.p<-as.surface( xg, z)
persp( out.p)
# also try plot( out.p) to see the default plot for a surface object
``` |

fields documentation built on May 19, 2017, 8:18 a.m.

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.