stat_prob_2d | R Documentation |
prob density
stat_prob_2d(
mapping = NULL,
data = NULL,
geom = "density_2d",
position = "identity",
...,
contour = TRUE,
contour_var = "density",
n = 100,
h = NULL,
adjust = c(1, 1),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
Use to override the default connection between |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Arguments passed on to
|
contour |
If |
contour_var |
Character string identifying the variable to contour
by. Can be one of |
n |
Number of grid points in each direction. |
h |
Bandwidth (vector of length two). If |
adjust |
A multiplicative bandwidth adjustment to be used if 'h' is
'NULL'. This makes it possible to adjust the bandwidth while still
using the a bandwidth estimator. For example, |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
library(ggplot2)
# Data
n = 200
set.seed(1)
a <- data.frame( x=rnorm(n, 10, 1.9), y=rnorm(n, 10, 1.2) )
b <- data.frame( x=rnorm(n, 14.5, 1.9), y=rnorm(n, 14.5, 1.9) )
c <- data.frame( x=rnorm(n, 9.5, 1.9), y=rnorm(n, 15.5, 1.9) )
data <- rbind(a,b,c)
# Show the area only
ggplot(data, aes(x=x, y=y) ) +
stat_prob_2d(aes(fill = ..level.., color =..level.. ), geom = "polygon")
ggplot(data, aes(x=x, y=y) ) +
stat_prob_2d(aes(fill = ..level..), geom = "polygon", color = "white")
ggplot(data, aes(x=x, y=y) ) +
stat_prob_2d(aes(color =..level.. ), geom = "path")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.