Skip to contents

Replacements for ggplot2::scale_size_area() and ggplot2::scale_size_binned_area() with convenient defaults for geom_hextile().

Usage

scale_size_tile(
  name = ggplot2::waiver(),
  ...,
  max_size = 1,
  oob = scales::squish
)

scale_size_binned_tile(
  name = ggplot2::waiver(),
  ...,
  max_size = 1,
  oob = scales::squish
)

Arguments

name

The name of the scale. Used as the axis or legend title. If waiver(), the default, the name of the scale is taken from the first mapping used for that aesthetic. If NULL, the legend title will be omitted.

...

Arguments passed on to ggplot2::continuous_scale() or ggplot2::binned_scale().

max_size

Size of largest points.

oob

One of:

  • Function that handles limits outside of the scale limits (out of bounds). Also accepts rlang lambda function notation.

  • The default (scales::squish()) squishes out of bounds values into range.

  • scales::censor() for replacing out of bounds values with NA.

  • scales::squish_infinite() for squishing infinite values into range.

Value

A ggplot2::Scale.

Details

These are convenience functions with the following changed defaults:

  • max_size = 1 rather than 6,

  • oob = scales::squish.

In practice, this makes it easy to set a hard upper limit on a scale, above which sizes are clamped to 1.

Examples

library(ggplot2)

d <- ggplot(diamonds, aes(carat, depth, z = price)) +
  geom_hextile()
d + scale_size_tile(limits = c(NA, 100))


d + scale_size_binned_tile(transform = "log10")