The curve()
function in R
is part of the graphic
package, which provides basic data visualization elements like box plots, bar plots, and so on.
curve()
is used to draw a curve for the equation specified in the arguments.
curve(expr, to, from, col)
expr
: This is the expression to be curved.from
: This is the start of the range to be evaluated for the expression.to
: This is the end of the range to be evaluated for the expression.col
: This is to specify the color of the curve. This is an optional parameter.Note: Other graphical parameters like
xlable
,ylabel
,main
, and so on, can also be passed as parameters.
f1 <- function(x) {sin(x) # Calculating Sine Value for the Plot.}curve(f1, -4, 4, col ="red") # Specifing the range between -4, 4.
sin(x)
. We store this in f1
.curve
. Here, f1
is passed as the expression, with a range from -4
to 4
. The optional parameter col
is set to "red"
.Free Resources