Learn R Programming

pracma (version 1.4.5)

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",
       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.
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.

See Also

curve

Examples

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

Run the code above in your browser using DataLab