Add a contour line figure to the chart.
fig_contour(
g,
...,
sync = TRUE,
data = NULL,
inherit_asp = TRUE,
colors = NULL,
nlevels = 10,
binwidth,
levels,
criticalRatio = 5,
type = c("line", "filled")
)
Arguments
g |
An object of class g2r or g2Proxy as returned by g2() or
g2_proxy() . |
... |
Options to pass to the figure, including asp() ,
and adjust() , active() , selected() , and config() ,
other key value pairs of are passed to
style. |
sync |
Whether to sync the axis data (align) with that
used in other figures, set to FALSE to not sync or set to
a character string to use as name of sync group. |
data |
A dataset (data.frame or tibble ) to use to
draw the figure. |
inherit_asp |
Whether to inherit the aspects paseed to
g2() initialisation function. |
colors |
A palette of colors to define the stroke
of each path. |
nlevels |
Passed to contoureR::getContourLines .
An integer number of bins to split the data into iff
‘levels’ or ‘binwidth’ have not been specified. |
binwidth |
Passed to contoureR::getContourLines .
The desired width of the bins, if specified, will override
‘nlevels’. |
levels |
Passed to contoureR::getContourLines .
A numeric vector of the explicitly specified levels (zvalues)
to contour, by specifying this argument, it will override
‘nlevels’ and/or ‘binwidth’. If this argument is provided,
the stacking order of the contours will be preserved in the
order of first occurence within the supplied vector. |
criticalRatio |
Passed to contoureR::getContourLines .
When producing the Delaunay Mesh, the quality of the mesh can
be poor in the proximity to the convex hull, Del's that have
an aspect ratio greater than this value are not considered when
producing the contours. In this context, the aspect ratio is
defined as the circumradius to twice its inradius, equilateral
triangles have an aspect ratio of 1, everything else is larger. |
type |
Whether to draw the lines or polygons. |
Details
Requires the x
, y
and z
aspects, the
width of the error bars can be changed with the size
aspect.
Examples
data(volcano)
x <- 1:nrow(volcano)
y <- 1:ncol(volcano)
df <- expand.grid(x = x, y = y)
df$z <- apply(df, 1, function(x) {
volcano[x[1], x[2]]
})
g <- g2(df, asp(x, y, z = z))
fig_contour(g)
fig_contour(g, colors = c("red", "blue"))
fig_contour(g, type = "filled", colors = c("darkblue", "white"))