Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:59:53+00:00 2026-06-09T11:59:53+00:00

The curve function in R provides a simple way to plot a function. For

  • 0

The curve function in R provides a simple way to plot a function. For example, this will plot a straight line

f1 <- function(x) x
curve(f1, from=-1, to=1)

Is there an equivalent function in R which takes a function with two argument (e.g., x and y) and ranges for both variables and produces a 3D plot?

For example, imagine I had the following function

f2 <- function(x, y) x + y

Is there a command similar to the following?

curve_3d(f2, x_range=c(-1, 1), y_range=c(-1, 1))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:59:54+00:00Added an answer on June 9, 2026 at 11:59 am

    The surface3d function in package:rgl looks like a good match. It would be very simple to create a wrapper that would take your function, create an x-y set of vectors with seq() and then pass those vectors to outer with your f2 as the FUN argument, and then call surface3d.

    There is also a persp3d which the authors (Duncan Murdoch and perhaps others) say is “higher level” and it does appear to add axes by default which surface3d does not.

    curve_3d <- function(f2, x_range=c(-1, 1), y_range=c(-1, 1), col=1:6 ){ 
           if (!require(rgl) ) {stop("load rgl")}
           xvec <- seq(x_range[1], x_range[2], len=15)
            yvec <- seq(y_range[1], y_range[2], len=15)
           fz <- outer(xvec, yvec, FUN=f2)
           open3d()
           persp3d( xvec, yvec, fz, col=col) }
    curve_3d(f2)
    snapshot3d("out3dplane.png")
    

    Rotatable pseudo3d plot of plane

    Now that I think about it further, you could have done something similar with persp() or wireframe(). The “trick” is using outer(…, FUN=fun). And as I think about it even further … the ability to use it with outer depends on it being composed of all vectorized operations. If they were not vectorized, we would need to rewrite with Vectorize or mapply.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a plot(x,y) is there any way to plot a line/curve/function that would split
A way to draw the curve corresponding to a given function is this: fun1
I'm looking for a way to draw a curve (perhaps a parametric function?) into
Is there any curve control in pyqt?, I have attached a image which is
The simple curve in this application only appears when it's dragged off the screen,
Is there a way of overlaying a mathematical function on top of data using
i'm searching for an equivalent of the javascript function quadraticCurveTo in php. ctx.moveTo(this.fromX,this.fromY); ctx.quadraticCurveTo(this.controlX,
Is there a function that adds a curve that fits the peaks if given
Is there an equivalent method for plotting functions using ggplot to the curve() command
I am trying to write a data calculated from this function in a file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.