This function creates a density plot.
densityPlot(
df,
title = "Density plot",
colorScheme = c("oasis", "sea", "lava", "custom"),
useSchemeDefaults = FALSE,
drawNN = TRUE,
drawScores = FALSE,
palette = NULL,
segColor = "plum1",
pointSize = 0.8,
pointColor = "red",
segType = c("dashed", "solid", "dotted", "dotdash", "longdash", "twodash"),
segWidth = 0.4,
legendPos = c("right", "none"),
nGridPoints = 300,
expandPerc = 20,
labelSize = 2.5,
labelColor = "black",
labelRepulsion = 1,
labelPull = 1,
maxOverlaps = Inf,
verbose = FALSE,
...
)An object of class gg.
A data frame with at least two columns, representing the x
and y coordinates of the points. A score column can also be provided
as the third column. Nearest neighbor information can be provided in the last
column as a character vector with elements selected from the rownames.
Plot title.
Color scheme.
Whether to use the default segColor,
pointColor and labelColor for scheme. Ignored
if colorScheme is set to 'custom'.
Whether to draw segments linking each point to its nearest neighbor.
Whether to render scores on the plot. If set to
TRUE, the third column of the input data frame will be numeric and
scores will be taken from there.
Color palette. Used only if color scheme is set to 'custom'.
Nearest neighbor segment color. Ignored if drawNN is
set to FALSE, or if useSchemeDefaults is TRUE and
colorScheme is different from 'custom'.
Point size.
Point color. Ignored if useSchemeDefaults
is TRUE and colorScheme is different from 'custom'.
Nearest neighbor segment type. Must choose between 'solid',
'dashed', 'dotted','dotdash', 'longdash' and 'twodash'. Ignored if
drawNN is set to FALSE.
Nearest neighbor segment width. Ignored if drawNN is
set to FALSE.
Legend position. Choose between 'right' and 'none'.
Number of grid points in each direction.
Percentage by which the grid will be expanded.
Size of labels of strata elements.
Label color. Ignored if useSchemeDefaults
is TRUE and colorScheme is different from 'custom'.
Repulsion strength between labels.
Attraction strength between a text label and its data point.
Maximum overlaps.
Whether output should be verbose.
Other arguments passed to centerTitle.
x <- c(1, 2, 3, 4, 6, 7, 8, 10, 12, 11, 3, 6, 4, 1, 13, 13, 14, 18, 16)
y <- c(1, 3, 1, 4, 3, 2, 8, 2, 1, 11, 8, 8, 10, 14, 13, 11, 11, 12,15)
z <- round(runif(19, 75, 100), 2)
df <- data.frame(x, y, z)
rownames(df) <- paste0('p', rownames(df))
densityPlot(df)
Run the code above in your browser using DataLab