This function will plot x,y coordinate values summarized in hexagons in a standardized manner

ggHex(
  x = NULL,
  y = NULL,
  color = NULL,
  pal = paletteContinuous(set = "solarExtra"),
  bins = 200,
  xlim = NULL,
  ylim = NULL,
  extend = 0.05,
  xlabel = "x",
  ylabel = "y",
  title = "",
  colorTitle = "values",
  baseSize = 6,
  ratioYX = 1,
  FUN = "median",
  hexCut = c(0.02, 0.98),
  addPoints = FALSE,
  ...
)

Arguments

x

A numeric vector containing the x-axis values for each point.

y

A numeric vector containing the y-axis values for each point.

color

A numeric/categorical vector containing coloring information for each point.

pal

A custom continuous palette from ArchRPalettes for coloration of hexes.

bins

The number of bins to be used for plotting the hexplot. bins indicates the total number of hexagons that will fit within the surface area of the plot.

xlim

A numeric vector of two values indicating the lower and upper bounds of the x-axis on the plot.

ylim

A numeric vector of two values indicating the lower and upper bounds of the y-axis on the plot.

extend

A numeric value indicating the fraction to extend the x-axis and y-axis beyond the maximum and minimum values if xlim and ylim are not provided. For example, 0.05 will extend the x-axis and y-axis by 5 percent on each end.

xlabel

The label to plot for the x-axis.

ylabel

The label to plot for the y-axis.

title

The title of the plot.

colorTitle

The label to use for the legend corresponding to color.

baseSize

The base font size (in points) to use in the plot.

ratioYX

The aspect ratio of the x and y axes on the plot.

FUN

The function to use for summarizing data into hexagons. Typically "mean" or something similar.

hexCut

If this is not null, a quantile cut is performed to threshold the top and bottom of the distribution of values. This prevents skewed color scales caused by strong outliers. The format of this should be c(a,b) where a is the upper threshold and b is the lower threshold. For example, hexCut = c(0.025,0.975) will take the top and bottom 2.5 percent of values and set them to the value of the 97.5th and 2.5th percentile values respectively.

addPoints

A boolean value indicating whether individual points should be shown on the hexplot.

...

Additional params for plotting

Examples


# Create Random Data
m <- data.frame(matrix(rnorm(300, 2),ncol=3))

# Plot
p <- ggHex(x = m[,1], y = m[,2], color = m[,3])

# To PDF
pdf("test.pdf", width = 4, height = 4)
p
dev.off()