scale_alpha: Alpha transparency scales

View source: R/scale-alpha.R

scale_alphaR Documentation

Alpha transparency scales

Description

Alpha-transparency scales are not tremendously useful, but can be a convenient way to visually down-weight less important observations. scale_alpha() is an alias for scale_alpha_continuous() since that is the most common use of alpha, and it saves a bit of typing.

Usage

scale_alpha(name = waiver(), ..., range = c(0.1, 1))

scale_alpha_continuous(name = waiver(), ..., range = c(0.1, 1))

scale_alpha_binned(name = waiver(), ..., range = c(0.1, 1))

scale_alpha_discrete(...)

scale_alpha_ordinal(name = waiver(), ..., range = c(0.1, 1))

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.

...

Other arguments passed on to continuous_scale(), binned_scale(), or discrete_scale() as appropriate, to control name, limits, breaks, labels and so forth.

range

Output range of alpha values. Must lie between 0 and 1.

See Also

The documentation on colour aesthetics.

Other alpha scales: scale_alpha_manual(), scale_alpha_identity().

The alpha scales section of the online ggplot2 book.

Other colour scales: scale_colour_brewer(), scale_colour_continuous(), scale_colour_gradient(), scale_colour_grey(), scale_colour_hue(), scale_colour_identity(), scale_colour_manual(), scale_colour_steps(), scale_colour_viridis_d()

Examples

p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(alpha = year))

# The default range of 0.1-1.0 leaves all data visible
p

# Include 0 in the range to make data invisible
p + scale_alpha(range = c(0, 1))

# Changing the title
p + scale_alpha("cylinders")

ggplot2 documentation built on June 22, 2024, 11:35 a.m.