From df8e93c344a00bbfdde03018902cce88a44012e0 Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:57:22 +0200 Subject: [PATCH] Set and document new arguments --- R/guide-axis.R | 24 +++++++++++++++++++++--- man/guide_axis.Rd | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/R/guide-axis.R b/R/guide-axis.R index 862e21cb96..e5393dde13 100644 --- a/R/guide-axis.R +++ b/R/guide-axis.R @@ -6,6 +6,14 @@ #' [scale_(x|y)_discrete()][scale_x_discrete()]. #' #' @inheritParams guide_legend +#' @param breaks,labels,minor.breaks Either `derive()` to indicate that the +#' breaks, labels or minor breaks should be taken from the scale, or valid +#' input to the scale's synonymous arguments to override the scale's settings. +#' By default, `breaks` and `labels` are derived from the scale, whereas +#' `minor.breaks` are omitted. +#' @param trans A `function`, `formula` or `` object that can perform +#' the transformation for secondary axes. Note that discrete scales cannot +#' be transformed. The default, `NULL`, will perform no transformation. #' @param check.overlap silently remove overlapping labels, #' (recursively) prioritizing the first, last, and middle labels. #' @param angle Compared to setting the angle in [theme()] / [element_text()], @@ -41,9 +49,19 @@ #' #' # can also be used to add a duplicate guide #' p + guides(x = guide_axis(n.dodge = 2), y.sec = guide_axis()) -guide_axis <- function(title = waiver(), check.overlap = FALSE, angle = NULL, - n.dodge = 1, cap = "none", order = 0, - position = waiver()) { +guide_axis <- function( + title = waiver(), + breaks = derive(), + labels = derive(), + minor.breaks = NULL, + trans = NULL, + check.overlap = FALSE, + angle = NULL, + n.dodge = 1, + cap = "none", + order = 0, + position = waiver() +) { if (is.logical(cap)) { check_bool(cap) diff --git a/man/guide_axis.Rd b/man/guide_axis.Rd index 086ba0b25a..cf90988581 100644 --- a/man/guide_axis.Rd +++ b/man/guide_axis.Rd @@ -6,6 +6,10 @@ \usage{ guide_axis( title = waiver(), + breaks = derive(), + labels = derive(), + minor.breaks = NULL, + trans = NULL, check.overlap = FALSE, angle = NULL, n.dodge = 1, @@ -20,6 +24,16 @@ If \code{NULL}, the title is not shown. By default (\code{\link[=waiver]{waiver()}}), the name of the scale object or the name specified in \code{\link[=labs]{labs()}} is used for the title.} +\item{breaks, labels, minor.breaks}{Either \code{derive()} to indicate that the +breaks, labels or minor breaks should be taken from the scale, or valid +input to the scale's synonymous arguments to override the scale's settings. +By default, \code{breaks} and \code{labels} are derived from the scale, whereas +\code{minor.breaks} are omitted.} + +\item{trans}{A \code{function}, \code{formula} or \verb{} object that can perform +the transformation for secondary axes. Note that discrete scales cannot +be transformed. The default, \code{NULL}, will perform no transformation.} + \item{check.overlap}{silently remove overlapping labels, (recursively) prioritizing the first, last, and middle labels.}