stat_summaries_hex {ggplot.multistats} | R Documentation |
Multi-Stat Binning Layer
Description
Very similar to stat_summary_hex
, but allows
for multiple stats to be captured using the funs
parameter.
Usage
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
Arguments
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 display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
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 |
Format
An object of class StatSummariesHex
(inherits from Stat
, ggproto
, gg
) of length 3.
See Also
normalize_function_list
for the funs
parameter
and draw_key_hexagon
for the legend entry.
Examples
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 `stat(value)` containing the mean
ggplot_base + stat_summaries_hex(aes(fill = stat(value)), bins = 5)
# but you can specify your own stats
ggplot_base + stat_summaries_hex(
aes(fill = stat(median), alpha = stat(n)),
funs = c('median', n = 'length'),
bins = 5)