R/scales-tern.R

Defines functions scale_R_continuous scale_L_continuous scale_T_continuous

Documented in scale_L_continuous scale_R_continuous scale_T_continuous

#' Ternary Position Scales
#' 
#' Define the ternary continuous position scales (T, L & R).
#' @inheritParams ggplot2::scale_x_continuous
#' @param ... not used
#' @author Nicholas Hamilton
#' @rdname scale_X_continuous
#' @name scale_X_continuous
#' @export
scale_T_continuous <- function(name         = waiver(), 
                               limits       = NULL,
                               breaks       = waiver(),
                               minor_breaks = waiver(),
                               labels       = waiver(),...) {
  sc <- continuous_scale(
    c("T"),
    # "tern_T", 
    palette = identity, 
    name = name, breaks = breaks,
    minor_breaks = minor_breaks, labels = labels, limits = limits,
    expand = waiver(), oob = censor, na.value = NA_real_, transform = "identity",
    guide = "none", super = ScaleContinuousPosition
  )
  # TODO: Fix this hack. We're reassigning the parent ggproto object, but this
  # object should in the first place be created with the correct parent.
  #sc$super <- ScaleContinuousPosition
  #class(sc) <- class(ScaleContinuousPosition)
  sc
}


#' @rdname scale_X_continuous
#' @export
scale_L_continuous <- function(name         = waiver(), 
                               limits       = NULL,
                               breaks       = waiver(),
                               minor_breaks = waiver(),
                               labels       = waiver(),...) {
  sc <- continuous_scale(
    c("L"),
    # "tern_L", 
    palette = identity, 
    name = name, breaks = breaks,
    minor_breaks = minor_breaks, labels = labels, limits = limits,
    expand = waiver(), oob = censor, na.value = NA_real_, transform = "identity",
    guide = "none",super = ScaleContinuousPosition
  )
  # TODO: Fix this hack. We're reassigning the parent ggproto object, but this
  # object should in the first place be created with the correct parent.
  #sc$super <- ScaleContinuousPosition
  #class(sc) <- class(ScaleContinuousPosition)
  sc
}

#' @rdname scale_X_continuous
#' @export
scale_R_continuous <- function(name         = waiver(), 
                               limits       = NULL,
                               breaks       = waiver(),
                               minor_breaks = waiver(),
                               labels       = waiver(),...) {
  sc <- continuous_scale(
    c("R"),
    # "tern_R", 
    palette = identity, 
    name = name, breaks = breaks,
    minor_breaks = minor_breaks, labels = labels, limits = limits,
    expand = waiver(), oob = censor, na.value = NA_real_, transform = "identity",
    guide = "none", super = ScaleContinuousPosition
  )
  # TODO: Fix this hack. We're reassigning the parent ggproto object, but this
  # object should in the first place be created with the correct parent.
  #sc$super <- ScaleContinuousPosition
  #class(sc) <- class(ScaleContinuousPosition)
  sc
}

Try the ggtern package in your browser

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

ggtern documentation built on June 22, 2024, 11:01 a.m.