plot_function_surface: Surface plot

View source: R/spotPlot.R

plot_function_surfaceR Documentation

Surface plot

Description

A (filled) contour plot or perspective plot of a function, interactive via plotly.

Usage

plot_function_surface(
  f = function(x) {
     rowSums(x^2)
 },
  lower = c(0, 0),
  upper = c(1, 1),
  type = "filled.contour",
  s = 100,
  xlab = "x1",
  ylab = "x2",
  zlab = "y",
  color.palette = terrain.colors,
  title = " ",
  levels = NULL,
  points1,
  points2,
  pch1 = 20,
  pch2 = 8,
  lwd1 = 1,
  lwd2 = 1,
  cex1 = 1,
  cex2 = 1,
  col1 = "blue",
  col2 = "red",
  ...
)

Arguments

f

function to be plotted. The function should either be able to take two vectors or one matrix specifying sample locations. i.e. z=f(X) or z=f(x2,x1) where Z is a two column matrix containing the sample locations x1 and x2.

lower

boundary for x1 and x2 (defaults to c(0,0)).

upper

boundary (defaults to c(1,1)).

type

string describing the type of the plot: "filled.contour" (default), "contour", "persp" (perspective), or "persp3d" plot. Note that "persp3d" is based on the plotly package and will work in RStudio, but not in the standard RGui.

s

number of samples along each dimension. e.g. f will be evaluated s^2 times.

xlab

lable of first axis

ylab

lable of second axis

zlab

lable of third axis

color.palette

colors used, default is terrain.color

title

of the plot

levels

number of levels for the plotted function value. Will be set automatically with default NULL.. (contour plots only)

points1

can be omitted, but if given the points in this matrix are added to the plot in form of dots. Contour plots and persp3d only. Contour plots expect matrix with two columns for coordinates. 3Dperspective expects matrix with three columns, third column giving the corresponding observed value of the plotted function.

points2

can be omitted, but if given the points in this matrix are added to the plot in form of crosses. Contour plots and persp3d only. Contour plots expect matrix with two columns for coordinates. 3Dperspective expects matrix with three columns, third column giving the corresponding observed value of the plotted function.

pch1

pch (symbol) setting for points1 (default: 20). (contour plots only)

pch2

pch (symbol) setting for points2 (default: 8). (contour plots only)

lwd1

line width for points1 (default: 1). (contour plots only)

lwd2

line width for points2 (default: 1). (contour plots only)

cex1

cex for points1 (default: 1). (contour plots only)

cex2

cex for points2 (default: 1). (contour plots only)

col1

color for points1 (default: "black"). (contour plots only)

col2

color for points2 (default: "black"). (contour plots only)

...

additional parameters passed to contour or filled.contour

Value

plotly visualization (based on plot_ly)


SPOTMisc documentation built on Sept. 5, 2022, 5:06 p.m.