Learn R Programming

soc.ca (version 0.8.0)

map.density: Density plot for the cloud of individuals

Description

Draws a 2d density plot on top of an existing soc.ca map. The density is calculated by the kde2d function from MASS and plotted by geom_density2d from ggplot2 map.density uses the coordinates of the individuals as a basis for the density calculation. Borders are arbitrary.

Usage

map.density(
  object,
  map = map.ind(object),
  group = NULL,
  color = "red",
  alpha = 0.8,
  size = 0.5,
  linetype = "solid"
)

Arguments

object

a soc.ca class object

map

a soc.ca map object created by one of the soc.ca mapping functions

group

a factor determining group membership. Density is mapped for each group individually.

color

a single value or vector determining the color. See the scale functions of ggplot2 for ways to alter the scales.

alpha

a single value or vector determining the alpha.

size

a single value or vector determining the size of the lines.

linetype

a single value or vector determining the linetype

Examples

Run this code
# NOT RUN {
example(soc.ca)
map.density(result, map.ind(result, dim = 2:3, point.alpha = 0.2))
map.density(result, map.ind(result, legend = TRUE, point.alpha = 0.2),
 group = duplicated(active), color = duplicated(active),
 linetype = duplicated(active))
map.density(result, map.ctr(result))
# }

Run the code above in your browser using DataLab