Graphics Reference
In-Depth Information
tion that actually generates the density estimate,
kde2d()
. In this example (
Figure 6-35
)
, we'll
use a smaller bandwidth in the xand ydirections, so that the density estimate is more closely
fitted (perhaps overfitted) to the data:
p
+
stat_density2d(aes(fill
=
..
density..), geom
=
"raster"
,
contour
=
FALSE
FALSE
, h
=
c(
.5
,
5
))
Figure 6-35. Density plot with a smaller bandwidth in the x and y directions
See Also
The relationship between
stat_density2d()
and
stat_bin2d()
is the same as the relation-
ship between their one-dimensional counterparts, the density curve and the histogram. The dens-
ity curve is an estimateof the distribution under certain assumptions, while the binned visualiza-