Learn R Programming

WVPlots (version 1.1.1)

HexBinPlot: Build a hex bin plot

Description

Build a hex bin plot with rational color coding.

Usage

HexBinPlot(d, xvar, yvar, title, ..., bins = 30, binwidth = NULL,
  na.rm = FALSE)

Arguments

d

data frame

xvar

name of x variable column

yvar

name of y variable column

title

plot title

...

not used, forces later arguments to bind by name

bins

passed to geom_hex

binwidth

passed to geom_hex

na.rm

passed to geom_hex

Value

a ggplot2 hexbin plot

Details

Builds a standard ggplot2 hexbin plot, with a color scale such that dense areas are colored darker (the default ggplot2 fill scales will color dense areas lighter).

Requires the hexbin package.

See Also

geom_hex

Examples

Run this code
# NOT RUN {
if(requireNamespace("hexbin", quietly = TRUE)) {
   set.seed(634267)
   dframe = data.frame(x = rnorm(1000), y = rnorm(1000))
   print(HexBinPlot(dframe, "x", "y", "Example hexbin"))

   diamonds = ggplot2::diamonds
   print(HexBinPlot(diamonds, "carat", "price", "Diamonds example"))
}

# }

Run the code above in your browser using DataLab