GGPLOT - geom_hex

Divides the plane into regular hexagons, counts the number of cases in each hexagon, then maps the number of cases to the hexagon fill and convert them with ggplotly.

d <- ggplot(diamonds, aes(carat, price))
p <-  d + geom_hex()
plotly::ggplotly(p)
d <- ggplot(diamonds, aes(carat, price))
p <-  d + geom_hex(bins = 10)
plotly::ggplotly(p)
d <- ggplot(diamonds, aes(carat, price))
p <-  d + geom_hex(bins = 30)
plotly::ggplotly(p)
d <- ggplot(diamonds, aes(carat, price))
p <-  d + geom_hex(binwidth = c(1, 1000))
plotly::ggplotly(p)
d <- ggplot(diamonds, aes(carat, price))
p <-  d + geom_hex(binwidth = c(.1, 500))
plotly::ggplotly(p)