diff --git a/R/scale-discrete-.R b/R/scale-discrete-.R index bb1518746f..a5ff3289a4 100644 --- a/R/scale-discrete-.R +++ b/R/scale-discrete-.R @@ -19,8 +19,9 @@ #' @param continuous.limits One of: #' * `NULL` to use the default scale range #' * A numeric vector of length two providing a display range for the scale. -#' * A function that accepts the existing continuous limits and returns a -#' numeric vector of length two. +#' Use `NA` to refer to the existing minimum or maximum. +#' * A function that accepts the limits and returns a numeric vector of +#' length two. #' @rdname scale_discrete #' @family position scales #' @seealso diff --git a/R/scale-expansion.R b/R/scale-expansion.R index ce61a1c5e3..9c682eeaa6 100644 --- a/R/scale-expansion.R +++ b/R/scale-expansion.R @@ -180,8 +180,7 @@ expand_limits_discrete <- function(limits, expand = expansion(0, 0), coord_limit check_numeric(continuous_limits, arg = "continuous.limits") check_length(continuous_limits, 2L, arg = "continuous.limits") missing <- is.na(continuous_limits) - limits <- range(ifelse(missing, limits, continuous_limits)) - coord_limits <- range(ifelse(missing, coord_limits, continuous_limits)) + limits <- ifelse(missing, range(limits), continuous_limits) } limit_info <- expand_limits_discrete_trans( diff --git a/man/scale_discrete.Rd b/man/scale_discrete.Rd index 7e6e251980..19e1df99fb 100644 --- a/man/scale_discrete.Rd +++ b/man/scale_discrete.Rd @@ -114,8 +114,9 @@ expand the scale by 5\% on each side for continuous variables, and by \itemize{ \item \code{NULL} to use the default scale range \item A numeric vector of length two providing a display range for the scale. -\item A function that accepts the existing continuous limits and returns a -numeric vector of length two. +Use \code{NA} to refer to the existing minimum or maximum. +\item A function that accepts the limits and returns a numeric vector of +length two. }} } \description{