stat_hex_kde: Function that first determines the kernel density of points...

View source: R/hexbin_kde.R

stat_hex_kdeR Documentation

Function that first determines the kernel density of points and then colors hexbin with those values.

Description

This is a function that first determines the kernel density of points and then colors hexbin with those values.

Usage

stat_hex_kde(
  mapping = NULL,
  data = NULL,
  geom = "hex",
  position = "identity",
  ...,
  show.legend = NA,
  inherit.aes = TRUE,
  bins = 175,
  densityMax = 0.98,
  kdeGrid = 175,
  binwidth = NULL,
  na.rm = TRUE,
  fun = "median",
  fun.args = list(),
  nPlot = 1e+05,
  xlim = NULL,
  ylim = NULL,
  kdeMethod = "grDevices"
)

Arguments

mapping

Set of aesthetic mappings created by ‘aes()’ or ‘aes_()’. If specified and ‘inherit.aes = TRUE’ (the default), it is combined with the default mapping at the top level of the plot. You must supply ‘mapping’ if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

     If ‘NULL’, the default, the data is inherited from the plot
     data as specified in the call to ‘ggplot()’.

     A ‘data.frame’, or other object, will override the plot data.
     All objects will be fortified to produce a data frame. See
     ‘fortify()’ for which variables will be created.

     A ‘function’ will be called with a single argument, the plot
     data. The return value must be a ‘data.frame’, and will be
     used as the layer data. A ‘function’ can be created from a
     ‘formula’ (e.g. ‘~ head(.x, 10)’).
geom

Override the default connection between ‘geom_hex’ and ‘stat_binhex.’

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

...

Other arguments passed on to ‘layer()’. These are often aesthetics, used to set an aesthetic to a fixed value, like ‘colour = "red"’ or ‘size = 3’. They may also be parameters to the paired geom/stat.

show.legend

show legend with geom.

inherit.aes

inherit aes from geom.

New Params

bins

numeric vector giving number of bins in both vertical and horizontal directions. Set to 175 by default.

densityMax

max density quantile allowed. Values above will be trimmed to the max density quantile.

kdeGrid

number of grids to use kernel density from grDevices/MASS. Default is set to 175.

binwidth

numeric vector giving bin width in both vertical and horizontal directions. Overrides bins if both set.

na.rm

remove NA values from summarizing.

fun

function to apply for hexbin summary of kde. Default is set to 'median'.

fun.args

arguments to supply to function for summary of hexbins.

nPlot

number of points to use for plot. Can be useful to use sampling. Set to 100000 by default.

xlim

x-limits to summarize over. values not in these limits will be discarded for hexbin kernel density estimation.

ylim

y-limits to summarize over. values not in these limits will be discarded for hexbin kernel density estimation.

kdeMethod

kernel density method to use "grDevices" or "Mass"


jeffmgranja/jgplot2 documentation built on Nov. 21, 2022, 4:55 a.m.