R/scale_edge_alpha.R

Defines functions scale_edge_alpha_identity scale_edge_alpha_manual scale_edge_alpha_binned scale_edge_alpha_discrete scale_edge_alpha

Documented in scale_edge_alpha scale_edge_alpha_binned scale_edge_alpha_discrete scale_edge_alpha_identity scale_edge_alpha_manual

#' Edge alpha scales
#'
#' This set of scales defines new alpha scales for edge geoms equivalent to the
#' ones already defined by ggplot2. See [ggplot2::scale_alpha()] for
#' more information. The different geoms will know whether to use edge scales or
#' the standard scales so it is not necessary to write `edge_alpha` in
#' the call to the geom - just use `alpha`.
#'
#' @return A ggproto object inheriting from `Scale`
#'
#' @family scale_edge_*
#'
#' @name scale_edge_alpha
#' @rdname scale_edge_alpha
#'
NULL

#' @rdname scale_edge_alpha
#'
#' @inheritParams ggplot2::scale_alpha
#'
#' @importFrom scales rescale_pal
#' @export
scale_edge_alpha <- function(..., range = c(0.1, 1)) {
  sc <- scale_alpha(..., range = range)
  sc$aesthetics <- 'edge_alpha'
  sc
}

#' @rdname scale_edge_alpha
#'
#' @export
scale_edge_alpha_continuous <- scale_edge_alpha

#' @rdname scale_edge_alpha
#'
#'
#' @inheritParams ggplot2::scale_alpha_discrete
#'
#' @export
scale_edge_alpha_discrete <- function(..., range = c(0.1, 1)) {
  sc <- scale_alpha_discrete(..., range = range)
  sc$aesthetics <- 'edge_alpha'
  sc
}

#' @rdname scale_edge_alpha
#'
#'
#' @inheritParams ggplot2::scale_alpha_binned
#'
#' @export
scale_edge_alpha_binned <- function(..., range = c(0.1, 1)) {
  sc <- scale_alpha_binned(..., range = range)
  sc$aesthetics <- 'edge_alpha'
  sc
}

#' @rdname scale_edge_alpha
#'
#' @inheritParams ggplot2::scale_alpha_manual
#'
#' @export
scale_edge_alpha_manual <- function(..., values, breaks = waiver(), na.value = NA) {
  sc <- scale_alpha_manual(..., values = values, breaks = breaks, na.value = na.value)
  sc$aesthetics <- 'edge_alpha'
  sc
}

#' @rdname scale_edge_alpha
#'
#' @inheritParams ggplot2::scale_alpha_identity
#'
#' @importFrom scales identity_pal
#' @export
scale_edge_alpha_identity <- function(..., guide = 'none') {
  sc <- scale_alpha_identity(..., guide = guide)
  sc$aesthetics <- 'edge_alpha'
  sc
}

Try the ggraph package in your browser

Any scripts or data that you put into this service are public.

ggraph documentation built on May 29, 2024, 2:32 a.m.