plot2D | R Documentation |
Accepts a function f(x,y) along with vectors, x and y and plots it in grayscale
function(X, Y, func, pl = T, gray.dens = 10^5, x.lab = NULL, y.lab = NULL)
function(X, Y, func, pl = T)
function(X, Y, func, pl = F)
X |
Describes the (numeric) vector in the X direction |
Y |
Describes the (numeric) vector in the Y direction |
func |
Describes the function used to calculate the Z return matrix |
pl |
Boolean bit used to specify whether plotting is needed or not. |
gray.dens |
Numeric value used to describe the grayscale density. |
x.lab |
Sets the label of the x-axis. |
y.lab |
Sets the label of the y-axis. |
X and Y need to be numeric vectors.
func needs to be a function.
for directly plotting a matrix, please see *plot2D.mat()*.
gray.dens has to be a whole number.
x.lab and y.lab have to be a single valued character vectors, if not NULL.
The returned value is always a numeric matrix.
If pl is set to TRUE, a plot is also produced.
The plot is always returned with an asp = 1.0.
Chitran Ghosal
#define the function
f_test <- function(x, y){
return(sin(5 * x) * cos(5 * y) + cos(x^2 + y^2))
}
#define the x-axis
x_seq <- seq(-10, 10, by = 0.01)
#define the y-axis
y_seq <- seq(-7, 7, by = 0.01)
#plot the function and get the matrix Z
Z = plot2D(X = x_seq, Y = y_seq, func = f_test, x.lab = 'X', y.lab = 'Y')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.