geom_tri_tern {ggtern} | R Documentation |
Tribin (ggtern version).
Description
Divides the plane into regular triangles, counts the number of cases in each triangles, and then (by default) maps the number of cases to the triangle fill.
Usage
geom_tri_tern(
mapping = NULL,
data = NULL,
stat = "tri_tern",
position = "identity",
...,
fun = sum,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
stat_tri_tern(
mapping = NULL,
data = NULL,
geom = "tri_tern",
position = "identity",
...,
bins = 30,
fun = sum,
centroid = FALSE,
na.rm = 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 |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
fun |
the scalar function to use for the statistic |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom , stat |
Override the default connection between 'geom_hex_tern' and 'stat_hex_tern' |
bins |
numeric vector giving number of bins in both vertical and horizontal directions. Set to 30 by default. |
centroid |
logical to return the centroid of the polygon, rather than the complete polygon |
Aesthetics
@section Aesthetics:
geom_hex()
understands the following aesthetics (required aesthetics are in bold):
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
Examples
set.seed(1)
n = 1000
df = data.frame(x = runif(n),
y = runif(n),
z = runif(n),
wt = runif(n))
#Equivalent of Hexbin
ggtern(df,aes(x,y,z)) +
geom_tri_tern(bins=10,aes(fill=..count..)) +
geom_point(size=0.25)
#Custom Function, Mean
ggtern(df,aes(x,y,z)) +
geom_tri_tern(bins=5,aes(fill=..stat..,value=wt),fun=mean) +
geom_point(size=0.25)