hexbin
package
In base R it is possible to create a hexbin chart making use of the hexbin
package, which contains a function of the same name to create a hexbin object that can be plotted.
Number of bins
The xbins
argument controls the number of bins. The default value is 30.
Border color
The border color of the hexagons can be customized with the boder
argument.
Color palette
The default gray color palette can be customized passing a color ramp palette to the colramp
argument. In the following example we are passing 12 colors of the viridis palette with the hcl.colors
function.
Legend width
The legend
argument allows customizing the width of the default legend. However, if the value is too small the legend will be cropped. Default value is 1.2.
Text size of the legend
You can also change the text size of the legend with lcex
.
Remove the legend
Finally, if you want to remove the legend set the legend
argument to FALSE
.
See also