View source: R/geom_contour_fill.R
geom_contour_fill | R Documentation |
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.
geom_contour_fill(
mapping = NULL,
data = NULL,
stat = "ContourFill",
position = "identity",
...,
breaks = MakeBreaks(),
bins = NULL,
binwidth = NULL,
proj = NULL,
proj.latlon = TRUE,
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,
proj.latlon = TRUE,
clip = NULL,
kriging = FALSE,
na.fill = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
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.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
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. |
proj.latlon |
Logical indicating if the projection step should project from a cartographic projection to a lon/lat grid or the other way around. |
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 for this layer.
When using a
|
geom_contour_fill
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
group
linetype
size
weight
An ordered factor that represents bin ranges.
Same as level
, but automatically uses scale_fill_discretised()
Lower and upper bin boundaries for each band, as well the mid point between the boundaries.
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()
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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.