Open In App

Create Line Curves for Specified Equations in R Programming – curve() Function

Last Updated : 10 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

curve() function in R Language is used to draw a curve for the equation specified in the argument.

Syntax: curve(expression, to, from, col)

Parameters:
expression: To be curved
to, from: range of curve plotting
col: color of curve

Example 1:




# R program to create a curve
  
# Creating curve using curve() function
curve(x ^ 2 + x + 5, -4, 4, col ="green", ylab ="y")


Output:

Example 2:




# R program to create a curve
  
# Creating curve using function
fun <- function(x) {x ^ 3 + 4}
curve(fun, -4, 4, col ="red", ylab ="y")


Output:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads