geom_contour_fill {metR} | R Documentation |
Filled 2d contours of a 3d surface
Description
While ggplot2's geom_contour
can plot nice contours, it
doesn't work with the polygon geom. This stat makes some small manipulation
of the data to ensure that all contours are closed and also computes a new
aesthetic int.level
, which differs from level
(computed by
ggplot2::geom_contour) in that represents
the value of the z
aesthetic inside the contour instead of at the edge.
It also computes breaks globally instead of per panel, so that faceted plots
have all the same binwidth.
Usage
geom_contour_fill(
mapping = NULL,
data = NULL,
stat = "ContourFill",
position = "identity",
...,
breaks = MakeBreaks(),
bins = NULL,
binwidth = NULL,
proj = NULL,
clip = NULL,
kriging = FALSE,
global.breaks = TRUE,
na.fill = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
stat_contour_fill(
mapping = NULL,
data = NULL,
geom = "polygon",
position = "identity",
...,
breaks = MakeBreaks(),
bins = NULL,
binwidth = NULL,
global.breaks = TRUE,
proj = NULL,
clip = NULL,
kriging = FALSE,
na.fill = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
breaks |
numeric vector of breaks |
bins |
Number of evenly spaced breaks. |
binwidth |
Distance between breaks. |
proj |
The projection to which to project the contours to. It can be either a projection string or a function to apply to the whole contour dataset. |
clip |
A simple features object to be used as a clip. Contours are only drawn in the interior of this polygon. |
kriging |
Whether to perform ordinary kriging before contouring.
Use this if you want to use contours with irregularly spaced data.
If |
global.breaks |
Logical indicating whether |
na.fill |
How to fill missing values.
|
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use to display the data, either as a
|
Aesthetics
geom_contour_fill
understands the following aesthetics (required aesthetics are in bold):
-
x
-
y
-
alpha
-
colour
-
group
-
linetype
-
size
-
weight
Computed variables
- level
An ordered factor that represents bin ranges.
- level_d
Same as
level
, but automatically usesscale_fill_discretised()
- level_low,level_high,level_mid
Lower and upper bin boundaries for each band, as well the mid point between the boundaries.
See Also
Other ggplot2 helpers:
MakeBreaks()
,
WrapCircular()
,
geom_arrow()
,
geom_contour2()
,
geom_label_contour()
,
geom_relief()
,
geom_streamline()
,
guide_colourstrip()
,
map_labels
,
reverselog_trans()
,
scale_divergent
,
scale_longitude
,
stat_na()
,
stat_subset()
Examples
library(ggplot2)
surface <- reshape2::melt(volcano)
ggplot(surface, aes(Var1, Var2, z = value)) +
geom_contour_fill() +
geom_contour(color = "black", size = 0.1)
ggplot(surface, aes(Var1, Var2, z = value)) +
geom_contour_fill(aes(fill = after_stat(level)))
ggplot(surface, aes(Var1, Var2, z = value)) +
geom_contour_fill(aes(fill = after_stat(level_d)))