HexBinPlot {WVPlots}R Documentation

Build a hex bin plot

Description

Build a hex bin plot with rational color coding.

Usage

HexBinPlot(
  d,
  xvar,
  yvar,
  title,
  ...,
  lightcolor = "#deebf7",
  darkcolor = "#000000",
  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

lightcolor

light color for least dense areas

darkcolor

dark color for most dense areas

bins

passed to geom_hex

binwidth

passed to geom_hex

na.rm

passed to geom_hex

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).

The user can choose an alternate color scale with endpoints lightcolor and darkcolor; it is up to the user to make sure that lightcolor is lighter than darkcolor.

Requires the hexbin package.

Value

a ggplot2 hexbin plot

See Also

geom_hex

Examples


if(requireNamespace("hexbin", quietly = TRUE)) {
   if (requireNamespace('data.table', quietly = TRUE)) {
	   # don't multi-thread during CRAN checks
		   data.table::setDTthreads(1)
   }
   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"))

   # change the colorscale
    print(HexBinPlot(diamonds, "carat", "price", "Diamonds example",
                     lightcolor="#fed98e",
                     darkcolor="#993404"))
}


[Package WVPlots version 1.3.8 Index]