plotHexDensity {hexDensity}R Documentation

Plotting method for hexagonal Kernel Density Estimation

Description

Adapted the plotting function from hexbin. X and Y axes now have the same scale with option for different aspect ratio. Ribbon legend for continuous data.

Usage

plotHexDensity(
  hexDensity,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  xaxt = TRUE,
  yaxt = TRUE,
  lcex = 1,
  colramp = colorRampPalette(col.viridis),
  colorcut = 1024,
  legend = TRUE,
  legendWidth = 0.05,
  legendDistance = 0.15,
  aspectRatio = diff(hexDensity@xbnds)/diff(hexDensity@ybnds),
  margin = 0.18,
  newpage = TRUE
)

Arguments

hexDensity

hexbin object returned by hexDensity

main

Main title

xlab, ylab

x-axis and y-axis label

xaxt, yaxt

Logical. Whether to plot x,y axes

lcex

Expansion factor for all letters.

colramp

Color function that accept an integer n and return n colors.

colorcut

An integer for the number of equi-spaced colorcut in [0,1] to assign colors to values. Alternatively, a vector of custom colorcut spacing between [0, 1].

legend

Legend is currently non-functional and should be ignored.

legendWidth

Expansion factor for legend width.

legendDistance

Expansion factor for the space between the plot and the legend.s

aspectRatio

width to height ratio of the plot. Default is the (inverse of) shape value of hexDensity.

margin

Minimum guaranteed margin for the plot. Different aspect ratio between the screen and the plot means that margin can be larger on certain sides.

newpage

logical for whether to plot on a new page.

Value

No return value

SIDE EFFECTS

Create kernel density estimate plot with hexagons

Author(s)

Dan Carr <dcarr@voxel.galaxy.gmu.edu>; ported and extended by Nicholas Lewin-Koh nikko@hailmail.net. Modified by Quoc Hoang Nguyen <nguyen.q@wehi.edu.au> for hexDensity.

Examples

set.seed(133)
d = hexDensity(x=rnorm(200),y=rnorm(200),bandwidth=0.15)
plotHexDensity(d)

[Package hexDensity version 1.4.9 Index]