How to create a hexbin chart in R

How to create a hexbin chart in R, The hexbin package in base R provides a function with the same name that creates a plottable hexbin object, which can be used to make a hexbin chart.

# install.packages("hexbin")
library(hexbin)
# Data
set.seed(123)
x <- rnorm(5000)
y <- rnorm(5000)
hex <- hexbin(x, y)
plot(hex)

How to do Conditional Mutate in R? – Data Science Tutorials

Number of bins

The number of bins is controlled by the xbins option. 30 is the default value.

hex <- hexbin(x, y, xbins = 20)
plot(hex)

Best Books to learn Tensorflow – Data Science Tutorials

Border color

hex <- hexbin(x, y)
plot(hex, border = 4)

Color palette

hex <- hexbin(x, y)
plot(hex, colramp = colorRampPalette(hcl.colors(12)))

What is Ad Hoc Analysis? – Data Science Tutorials

Remove the legend

hex <- hexbin(x, y)
plot(hex, legend = FALSE,
     colramp = colorRampPalette(hcl.colors(12, "GnBu"))) 

Convert multiple columns into a single column-tidyr Part4 (datasciencetut.com)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

four × two =

Ads Blocker Image Powered by Code Help Pro

Quality articles need supporters. Will you be one?

You currently have an Ad Blocker on.

Please support FINNSTATS.COM by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO