Arrange over-plotted points on a honeycomb lattice and dodge groups side-to-side
position_honeycombdodge.RdThis function applies the honeycomb position adjustment alongside the dodge
position adjustment, arranging overlapping points per x, y, and group on a
hexagonal lattice. See the position_honeycomb() documentation for more
information.
Arguments
- width
The dodging width, which defaults to 1.
- density
The pattern density, which defaults to 1 but will have to be adjusted in most cases. The desirable density will depend on both the ranges of the axes and the dimensions of the image.
- aspect_ratio
An aspect ratio adjustment to compensate for distortion of the circular arrangement, which might occur when plotting if coord_equal() is not used. A wide aspect ratio (e.g., 2) would adjust for vertical stretching, whereas a tall aspect ratio (e.g., 0.5) would adjust for horizontal stretching. The default aspect ratio of 1 is appropriate when no adjustment is required. Under coord_fixed(), set
aspect_ratioto the same value as that function'sratioargument.- orientation
The axis along which groups are separated, either
"x"(the default, side-to-side) or"y"(up and down). Matches the argument of the same name inggplot2::position_dodge().
Examples
library(ggplot2)
dat <- data.frame(
x = rep(1, 300),
y = rep(1, 300),
type = factor(sample(LETTERS[1:2], 300, replace = TRUE))
)
ggplot(dat, aes(x, y, color = type, shape = type)) +
geom_point(position = position_honeycombdodge(width = 1, density = 30)) +
coord_equal()