Dear All, The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R? Thanks in advance, Paul
How to draw the graph of f(x,y) = x * y ?
8 messages · Duncan Murdoch, Ben Bolker, robin hankin +2 more
On 9/23/2008 12:54 PM, Paul Smith wrote:
Dear All, The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R?
No, you would have to write it yourself. The basic idea is to use outer() to construct a matrix of function evaluations, then plot the matrix using persp, contour, image, rgl::persp3d, etc. There are examples on the ?contour man page. Duncan Murdoch
On Tue, Sep 23, 2008 at 6:32 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R?
No, you would have to write it yourself. The basic idea is to use outer() to construct a matrix of function evaluations, then plot the matrix using persp, contour, image, rgl::persp3d, etc. There are examples on the ?contour man page.
Thanks, Duncan. perps does what I was looking for. Paul
Paul Smith <phhs80 <at> gmail.com> writes:
The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R?
There is a curve3d function in the emdbook package on CRAN.
Paul you might find the view() function in the 'elliptic' package useful. This function implements various methods to visualize functions over the complex plane. HTH rksh
Paul Smith wrote:
Dear All, The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R? Thanks in advance, Paul
______________________________________________ R-help at r-project.org 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.
Robin K. S. Hankin Senior Research Associate Cambridge Centre for Climate Change Mitigation Research (4CMR) Department of Land Economy University of Cambridge rksh1 at cam.ac.uk 01223-764877
On Wed, Sep 24, 2008 at 4:05 AM, Ben Bolker <bolker at ufl.edu> wrote:
The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R?
There is a curve3d function in the emdbook package on CRAN.
Thanks, Ben and Robin. I think curve3d should be included in the base of R. It would help many users, I believe. I do not know whether curve3d could be extended to draw constant functions and functions like f(x,y) = x. With the current version, I get the following:
curve3d(1)
Error in curve3d(1) : 'expr' must be a function or an expression containing 'x' and 'y'
curve3d(x)
Error in eval(expr, envir, enclos) : could not find function "x"
Paul
You could always try F(x,y) = f(x) + 0*y That is "zero out" the degenerate dimensions. Of course you'll be plotting what is essentially a two dimensional object as if it were three dimensional. The degeneracy in y means a 2-D curve will be "extruded" along the Y dimension. Robert Farley Metro www.Metro.net -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Paul Smith Sent: Wednesday, September 24, 2008 06:20 To: r-help at stat.math.ethz.ch Subject: Re: [R] How to draw the graph of f(x,y) = x * y ?
On Wed, Sep 24, 2008 at 4:05 AM, Ben Bolker <bolker at ufl.edu> wrote:
The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R?
There is a curve3d function in the emdbook package on CRAN.
Thanks, Ben and Robin. I think curve3d should be included in the base of R. It would help many users, I believe. I do not know whether curve3d could be extended to draw constant functions and functions like f(x,y) = x. With the current version, I get the following:
curve3d(1)
Error in curve3d(1) : 'expr' must be a function or an expression containing 'x' and 'y'
curve3d(x)
Error in eval(expr, envir, enclos) : could not find function "x"
Paul ______________________________________________ R-help at r-project.org 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.
On Wed, Sep 24, 2008 at 4:14 PM, Farley, Robert <FarleyR at metro.net> wrote:
You could always try F(x,y) = f(x) + 0*y That is "zero out" the degenerate dimensions. Of course you'll be plotting what is essentially a two dimensional object as if it were three dimensional. The degeneracy in y means a 2-D curve will be "extruded" along the Y dimension. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Paul Smith Sent: Wednesday, September 24, 2008 06:20 To: r-help at stat.math.ethz.ch Subject: Re: [R] How to draw the graph of f(x,y) = x * y ? On Wed, Sep 24, 2008 at 4:05 AM, Ben Bolker <bolker at ufl.edu> wrote:
The function curve() draws the graph of functions from R to R. Is there some homologous function to curve() to draw functions from R^2 to R?
There is a curve3d function in the emdbook package on CRAN.
Thanks, Ben and Robin. I think curve3d should be included in the base of R. It would help many users, I believe. I do not know whether curve3d could be extended to draw constant functions and functions like f(x,y) = x. With the current version, I get the following:
curve3d(1)
Error in curve3d(1) : 'expr' must be a function or an expression containing 'x' and 'y'
curve3d(x)
Error in eval(expr, envir, enclos) : could not find function "x"
Thanks, Robert. your suggestion works to plot f(x,y) = x + 0*y, but it does not work in the case of f(x,y) = 1 + 0*x +0*y. Paul