
Contours: isobands, clipping, band quantities, labels, smoothing
Source:R/Contours.R
ContourFill.Rdz[i, j] is the value at (xs[j], ys[i]); the contour lines
themselves come from IsoLines. ContourFill: isobands between consecutive levels; each cell
is split into two triangles (the field is linear on a triangle) and each
triangle is clipped to levels[k] <= z < levels[k + 1]; areas are exact
for the piecewise-linear interpolant. ContourBands: the isobands with
a grey shade per band. ContourClip: polyline pieces inside a convex
counter-clockwise polygon (Sutherland and Hodgman 1974). ContourQuantity:
area and integral of the field where lower <= z < upper (each clipped
polygon is fanned into triangles; the integral of a linear field over a
triangle is its area times the mean of the three vertex values).
ContourLabels: label at the midpoint of the straightest run of each
polyline (smallest neighbouring turning angles, ties to the longest segment)
with the text angle along it. ContourSmooth: uniform B-spline through
the vertices as control points (de Boor recurrence; clamped knots for open
curves, wrapped control points for closed ones).
Usage
ContourFill(z, xs, ys, levels)
ContourBands(z, xs, ys, levels, shades = NULL)
ContourClip(lines, polygon)
ContourQuantity(z, xs, ys, lower, upper)
ContourLabels(lines, min_length = 0)
ContourSmooth(line, degree = 3, samples = 50, closed = FALSE)Arguments
- z
Numeric matrix of field values.
- xs, ys
Grid coordinates of the columns and rows of
z.- levels
Contour levels (band edges for the fill functions).
- shades
Optional shade per band (default grey levels 0.9 to 0.2).
- lines
List of polylines, each a two-column matrix of vertices.
- polygon
Convex clip polygon, two-column matrix, counter-clockwise.
- lower, upper
Band limits for
ContourQuantity.- min_length
Polylines shorter than this get no label.
- line
One polyline (two-column matrix) to smooth.
- degree
B-spline degree.
- samples
Number of evaluation points.
- closed
Treat the polyline as closed.