O'Reilly logo

R Data Visualization Cookbook by Atmajitsinh Gohil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a hexbin plot

Hexbin plots can be viewed as an alternative to scatter plots. The hexagon-shaped bins were introduced to plot densely packed sunflower plots. They can be used to plot scatter plots with high-density data. We will use the hexbin package available in R to plot hexagon-shaped bins on a plot instead of a sunflower.

Creating a hexbin plot

Getting ready

To generate a hexbin plot, we will use the hexbin package in R along with the generic rnorm() function.

How to do it…

The install.packages() and library() functions assist in installing the package as well as loading it in R:

install.packages("hexbin")
library(hexbin)

For the purpose of this recipe, we will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required