Learn R Programming

pracma (version 1.9.3)

ezplot: Easy Function Plot

Description

Easy function plot/wo the need to define x, y coordinates.

Usage

ezplot( f, a, b, n = 101, col = "blue", add = FALSE, lty = 1, lwd = 1, marker = 0, pch = 1, grid = TRUE, gridcol = "gray", fill = FALSE, fillcol = "lightgray", xlab = "x", ylab = "f (x)", main = "Function Plot", ...)

Arguments

f
Function to be plotted.
a, b
Left and right endpoint for the plot.
n
Number of points to plot.
col
Color of the function graph.
add
logical; shall the polt be added to an existing plot.
lty
line type; default 1.
lwd
line width; default 1.
marker
no. of markers to be added to the curve; defailt: none.
pch
poimt character; default circle.
grid
Logical; shall a grid be plotted?; default TRUE.
gridcol
Color of grid points.
fill
Logical; shall the area between function and axis be filled?; default: FALSE.
fillcol
Color of fill area.
xlab
Label on the x-axis.
ylab
Label on the y-axis.
main
Title of the plot
...
More parameters to be passed to plot.

Value

Plots the function graph and invisibly returns NULL.

Details

Calculates the x, y coordinates of points to be plotted and calls the plot function.

If fill is TRUE, also calls the polygon function with the x, y coordinates in appropriate order.

If the no. of markers is greater than 2, this number of markers will be added to the curve, with equal distances measured along the curve.

See Also

curve

Examples

Run this code
## Not run: 
# fun <- function(x) x * cos(0.1*exp(x)) * sin(0.1*pi*exp(x))
# ezplot(fun, 0, 5, n = 1001, fill = TRUE)
#   ## End(Not run)

Run the code above in your browser using DataLab