Plots of functions of two variables (which can be mapped to continuously-spaced scalar fields), for both rectangular and triangular areas.
#x-y-fv versions
#(main argument is a matrix)
plot_cfield (x, y, fv, fb, …,
contours=TRUE, heatmap=TRUE, contour.labels=FALSE,
main, xlab="x", ylab="y", xat, yat, xlabs, ylabs,
xyrel = test.xyrel (x, y, fv),
add=FALSE, axes=TRUE, reverse=FALSE,
ncontours=6, clabs,
contour.color="#000000",
color.function, color.fit, hcv=FALSE)plot_surface (x, y, fv, …,
grid.lines=TRUE,
main, xlab="x", ylab="y", xat, yat, xlabs, ylabs,
zlim, axes=TRUE, arrows=TRUE,
grid.color, color.function, color.fit)
plot_tricontour (x, y, fv, fb, …,
contours=TRUE, heatmap=TRUE, contour.labels=FALSE,
main, xlab="x", ylab="y",
xyrel="s",
axes=TRUE,
ncontours=6, clabs,
contour.color="#000000",
color.function, color.fit, hcv=FALSE)
plot_trisurface (x, y, fv, …,
grid.lines=TRUE,
main, xlab="x", ylab="y",
zlim, axes=TRUE, arrows=TRUE,
grid.color, color.function, color.fit)
#functional versions
#(which call the x-y-fv versions above)
plotf_cfield (f, xlim, ylim=xlim, …, n=30)
plotf_surface (f, xlim, ylim=xlim, zlim, …, n=30)
plotf_tricontour (f, …, n=30)
plotf_trisurface (f, …, n=30)
Optional sorted numeric vectors of x and y coordinates, refer to details. In the triangular case, ignored.
A numeric matrix (representing a continuously-spaced scalar field), which may not include NAs. In the triangular case, fv needs to be a square matrix, but only the top-left triangle is used, including the diagonal.
Optional numeric vector of function values (or "levels"), for contours.
Logical, include grid lines.
Logical, include contour lines.
Logical, include heatmap.
Logical, include contour labels.
Optional strings, main/axes titles.
Optional numeric vectors, the x and y axes tick points.
Optional character vectors, the x and y axes tick labels. In 3D plots, ignored unless axes is true and arrows is false.
Single character, either "f", "s" or "m". "f" produces a plot with a fixed aspect ratio of one, "s" produces a square plot, and "m" a maximized plot.
Logical, if true add contours/heatmap to an existing plot.
Logical vector of length one or two, if true plot reference arrows or axis ticks with labels.
Logical vector of length one or two, (subject to axes, above) if true, plot reference arrows, if false, use axis ticks with labels.
Logical vector of one or two, to reverse the x and y axes. Note that this argument could change.
Integer, the number of contour lines. Ignored if fb supplied.
Optional character vector of contour labels.
String, giving the grid line color.
Character vector of length one or with the same length as the number of contours, giving the contour line colors.
Optional color function, such as an arbitrary litmus object (for plot_surface) or an opaque litmus object (for the other plots), refer to details.
Optional color fitting function, such as a litmus.fit wrapper, refer to details.
Logical, use the high color variation option, refer to details.
In the rectangular case, a numeric-valued function of two variables (x and y), suitable for use with base::outer. In the triangular case, a similar function, but of three variables (w1, w2, w3) or (x, y and z) etc, with values between zero and one, which in general, sum to one.
Length-2 numeric vectors, the x and y ranges. Currently, these need to be ascending.
Length-2 numeric vector, the vertical range, corresponding to the value of the function or matrix.
An integer vector of length one or two, giving the number of grid points.
In the x-y-fv versions, ignored.
These functions produce combined contour-heat plots and 3d surface plots, for rectangular (and triangular) continuously-spaced scalar fields.
This can be used to plot numeric matrices (here, labelled as fv), and functions that can be mapped to numeric matrices.
In contrast to the discretely-spaced case, each heatmap bin represents one area between four (or three) fv points.
Increasing rows in fv correspond to increasing x values and increasing columns in fv correspond to increasing y values. If the x vector is supplied its length needs to equal the number of rows. Likewise, if the y vector is supplied its length needs to equal the number of columns.
Currently, surface plots use a diamond-based projection with a fixed viewing angle, such that the origin is at the bottom center.
If none of color.function and color.fit are supplied, then: (1) A color.fit function is determined by global options. (2) The color.fit function is used to compute a color.function from interpolated bin values (in heatmaps) or the magnitudes of their gradients (for surface plots). (3) The color.function is used to compute a color matrix from the interpolated bin values or magnitudes.
The color function can be any function that maps a numeric vector/matrix to a character vector/matrix of R colors, however, I recommend using litmus objects. The color fit function can be any function that maps a numeric vector to a valid color function, however, I recommend using a litmus.fit wrapper.
Note that: (1) In the plot_* functions (not the plotf_* functions) the only argument that's required is fv. (2) There's no guarantee that default contour lines will be suitable. (3) If using plot_surface or plot_trisurface to plot near-constant values, set zlim, for a better result. (4) In publication graphics, you may want to increase the resolution of the heatmap. (5) Only opaque color functions should be used in heatmaps, that is, color functions that produce opaque colors with no transparency. However, surface plots may use semitransparent colors.
Expanding on point (3), functions that are constant in theory, may product non-constant (but near-constant) values when computed via floating point arithmetic.
Refer to the vignette for an overview, references and better examples.
Discretely-spaced versions: plot_dfield
Plots of scalar fields over three variables: plot_contour_3d, plot_cfield_3d
Other functions: litmus, litmus.fit
# NOT RUN {
x <- y <- seq (-15.5, 15.5, length.out=40)
fv <- outer (x, y, rotated.sinc)
plot_cfield (,,fv)
plot_surface (,,fv)
# }
Run the code above in your browser using DataLab