These versions of the histogram and density geoms have been designed
specifically for diagonal plotting with
facet_matrix(). They differ from
ggplot2::geom_density() in that they
defaults to mapping
they ignore the y scale of the panel and fills it out, and they work for both
continuous and discrete x scales.
geom_autodensity( mapping = NULL, data = NULL, stat = "autodensity", position = "floatstack", ..., bw = "nrd0", adjust = 1, kernel = "gaussian", n = 512, trim = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_autohistogram( mapping = NULL, data = NULL, stat = "autobin", position = "floatstack", ..., bins = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
Set of aesthetic mappings created by
The data to be displayed in this layer. There are three options:
Use to override the default connection between
Position adjustment, either as a string, or the result of a call to a position adjustment function.
Other arguments passed on to
The smoothing bandwidth to be used.
If numeric, the standard deviation of the smoothing kernel.
If character, a rule to choose the bandwidth, as listed in
A multiplicate bandwidth adjustment. This makes it possible
to adjust the bandwidth while still using the a bandwidth estimator.
Kernel. See list of available kernels in
number of equally spaced points at which the density is to be
estimated, should be a power of two, see
logical. Should this layer be included in the legends?
Number of bins. Overridden by
facet_matrix for creating matrix grids
# A matrix plot with a mix of discrete and continuous variables p <- ggplot(mpg) + geom_autopoint() + facet_matrix(vars(drv:fl), layer.diag = 2, grid.y.diag = FALSE) p# Diagonal histograms p + geom_autohistogram()# Diagonal density distributions p + geom_autodensity()# You can use them like regular layers with groupings etc p + geom_autodensity(aes(colour = drv, fill = drv), alpha = 0.4)