Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ggally_density

Bivariate density plot


Description

Make a 2D density plot from a given data.

Usage

ggally_density(data, mapping, ...)

Arguments

data

data set using

mapping

aesthetics being used

...

parameters sent to either stat_density2d or geom_density2d

Details

The aesthetic "fill" determines whether or not stat_density2d (filled) or geom_density2d (lines) is used.

Author(s)

Barret Schloerke

Examples

# Small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive

data(tips, package = "reshape")
p_(ggally_density(tips, mapping = ggplot2::aes(x = total_bill, y = tip)))
p_(ggally_density(tips, mapping = ggplot2::aes_string(x = "total_bill", y = "tip")))
p_(ggally_density(
  tips,
  mapping = ggplot2::aes_string(x = "total_bill", y = "tip", fill = "..level..")
))
p_(ggally_density(
  tips,
  mapping = ggplot2::aes_string(x = "total_bill", y = "tip", fill = "..level..")
) + ggplot2::scale_fill_gradient(breaks = c(0.05, 0.1, 0.15, 0.2)))

GGally

Extension to 'ggplot2'

v2.1.1
GPL (>= 2.0)
Authors
Barret Schloerke [aut, cre], Di Cook [aut, ths], Joseph Larmarange [aut], Francois Briatte [aut], Moritz Marbach [aut], Edwin Thoen [aut], Amos Elberg [aut], Ott Toomet [ctb], Jason Crowley [aut], Heike Hofmann [ths], Hadley Wickham [ths]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.