View source: R/stat_summaries_hex.r
stat_summaries_hex | R Documentation |
Very similar to stat_summary_hex
, but allows
for multiple stats to be captured using the funs
parameter.
stat_summaries_hex(
mapping = NULL,
data = NULL,
geom = "hex",
position = "identity",
...,
bins = 30,
binwidth = NULL,
drop = TRUE,
funs = c(value = "mean"),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
key_glyph = NULL
)
StatSummariesHex
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
bins |
numeric vector giving number of bins in both vertical and horizontal directions. Set to 30 by default. |
binwidth |
Numeric vector giving bin width in both vertical and
horizontal directions. Overrides |
drop |
drop if the output of |
funs |
A list or vector of functions and function names.
See |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
key_glyph |
A legend key drawing function or a string providing
the function name minus the |
An object of class StatSummariesHex
(inherits from Stat
, ggproto
, gg
) of length 4.
normalize_function_list
for the funs
parameter
and draw_key_hexagon
for the legend entry.
library(ggplot2)
# Define the variable used for the stats using z
ggplot_base <- ggplot(iris, aes(Sepal.Width, Sepal.Length, z = Petal.Width))
# The default is creating `after_stat(value)` containing the mean
ggplot_base + stat_summaries_hex(aes(fill = after_stat(value)), bins = 5)
# but you can specify your own stats
ggplot_base + stat_summaries_hex(
aes(fill = after_stat(median), alpha = after_stat(n)),
funs = c('median', n = 'length'),
bins = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.