# DrawDensityMap: Graphic representation of a point density map In VecStatGraphs2D: Vector Analysis using Graphical and Analytical Methods in 2D

## Description

The density map will be built as follows: a) vectors are moved to a common origin without changing its azimuth and module; b) end positions perform a point cloud of varying density that depends on the accumulation of vectors with similar properties; and c) end positions are used to calculate the density map as a surface with values depending on the end-position accumulation per area unit. The density map provides information about the joint distribution of modules and azimuths and allows the detection of errors or outliers. Areas in which there is a greater number of points (end position of the vectors) will have a deeper color (red), whereas the areas with lower density will have a less intense color (white). The user can define how many points are classified as outliers. The outliers can be calculated using the higher value of the modules or the harmonic mean. For that, the module value or harmonic mean value is calculated for each vector. Points with the largest module value or harmonic mean value will be considered as outliers.

## Usage

 ```1 2 3``` ``` DrawDensityMap(data_x, data_y, PercentageOutliers = 5, PaintPoint = FALSE, Div = 250, HarmonicMean = FALSE, PaintAxis = FALSE, SVGf=0) ```

## Arguments

 `data_x` Vector containing the values of the X coordinates `data_y` Vector containing the values of the Y coordinates `PercentageOutliers` Integer value that indicates the percentage of points that are considered as outliers. The default value is 5 `PaintPoint` Logical value. If PaintPoint=TRUE, then samples are represented by points. If PaintPoint=FALSE, then samples are not represented by points. The default value is FALSE `Div` Integer value that indicates the number of divisions that will have the density map. The default value is 250 `HarmonicMean` Logical value. If HarmonicMean=FALSE, then the module is used for the calculation of outliers. If HarmonicMean=TRUE, then the harmonic mean is used for the calculation of outliers. The default value is FALSE. `PaintAxis` Logical value. If PaintAxis=TRUE, then the axis will be drawn. If PaintAxis=FALSE, then the axis will not be drawn. The default value is FALSE. `SVGf` Integer value. If SVGf = 0, the plot is showed only in the graphic window. If SVGf = 1, then the plot is saved as SVG graphic. The default value is 0.

## Details

Kernel descriptors are used to create the density map. To perform these calculations, the MASS package is required.

The parameter Div is very important because a very large value will lead to the creation of a slow density map, whereas a very small value will create an ineffective density map.

One way to obtain a set of X and Y coordinates of the vectors is to use the `LoadData` function.

Typical usages are

 ```1 2 3 4 5 6 7``` ``` DrawDensityMap(data_x, data_y, \dots) DrawDensityMap(data_x, data_y, Div = 100, \dots) DrawDensityMap(data_x, data_y, PaintPoint = TRUE, HarmonicMean = TRUE, PaintAxis = TRUE, \dots) ...... ```

## Value

This function returns no value and creates a graph that represents a density map from the input values.

## Author(s)

Ruiz-Cuetos, J.C., jcruizcue@gmail.com, Felicisimo, A.M., amfeli@unex.es, Cuartero, A., acuartero@unex.es, Polo, M.E., mepolo@unex.es, Rodriguez, P.G. pablogr@unex.es

## References

Dixon K. R., Chapman J. A. (1980) Harmonic mean measure of animal activity areas. Ecology 61, 1040-1044.

`DrawAzimuthDensity`, `DrawHistogram`, `DrawDistribution`, `DrawPoints`,
`DrawModuleAndAzimuthDistribution`, `DrawVectors`.
 ```1 2 3 4 5 6``` ``` FileName<-system.file("data/RectangularData.txt", package="VecStatGraphs2D") dat<-LoadData(FileName, Type=2) X_coordinate<-dat[,3] Y_coordinate<-dat[,4] DrawDensityMap(X_coordinate, Y_coordinate, PaintPoint = TRUE, Div=200, SVGf=0) ```