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.
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
)
No return value
hexbin object returned by hexDensity
Main title
x-axis and y-axis label
Logical. Whether to plot x,y axes
Expansion factor for all letters.
Color function that accept an integer n and return n colors.
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 is currently non-functional and should be ignored.
Expansion factor for legend width.
Expansion factor for the space between the plot and the legend.s
width to height ratio of the plot. Default is the (inverse of) shape value of hexDensity.
Minimum guaranteed margin for the plot. Different aspect ratio between the screen and the plot means that margin can be larger on certain sides.
logical for whether to plot on a new page.
Create kernel density estimate plot with hexagons
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.
set.seed(133)
d = hexDensity(x=rnorm(200),y=rnorm(200),bandwidth=0.15)
plotHexDensity(d)
Run the code above in your browser using DataLab