From 142d3d3bd0bbee8d42eae91402ee5d75b27f1103 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 2 Oct 2024 14:13:04 +0200 Subject: [PATCH] document --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/breaks-log.R | 24 ++++++++++++++++++++++++ man/minor_breaks_log.Rd | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 man/minor_breaks_log.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 38d99259..0ee8fe58 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,4 +39,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyLoad: yes Roxygen: list(markdown = TRUE, r6 = FALSE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index 323e34ba..678f6524 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -138,6 +138,7 @@ export(log_trans) export(logit_trans) export(manual_pal) export(math_format) +export(minor_breaks_log) export(minor_breaks_n) export(minor_breaks_width) export(modulus_trans) diff --git a/R/breaks-log.R b/R/breaks-log.R index 61fdeef6..cbfe7cfc 100644 --- a/R/breaks-log.R +++ b/R/breaks-log.R @@ -82,6 +82,30 @@ breaks_log <- function(n = 5, base = 10) { #' @rdname breaks_log log_breaks <- breaks_log +#' Minor breaks for log-10 axes +#' +#' This break function is designed to mark every power, multiples of 5 and/or 1 +#' of that power for base 10. +#' +#' @param detail Any of `1`, `5` and `10` to mark multiples of +#' powers, multiples of 5 of powers or just powers respectively. +#' @param smallest Smallest absolute value to mark when the range includes +#' negative numbers. +#' +#' @return A function to generate minor ticks. +#' @export +#' +#' @examples +#' # Standard usage with log10 scale +#' demo_log10(c(1, 1e10), minor_breaks = minor_breaks_log()) +#' # Increasing detail over many powers +#' demo_log10(c(1, 1e10), minor_breaks = minor_breaks_log(detail = 1)) +#' # Adjusting until where to draw minor breaks +#' demo_continuous( +#' c(-1000, 1000), +#' transform = asinh_trans(), +#' minor_breaks = minor_breaks_log(smallest = 1) +#' ) minor_breaks_log <- function(detail = NULL, smallest = NULL) { if (!is.null(detail) && (!length(detail) == 1 || !detail %in% c(1, 5, 10))) { cli::cli_abort("The {.arg detail} argument must be one of 1, 5 or 10.") diff --git a/man/minor_breaks_log.Rd b/man/minor_breaks_log.Rd new file mode 100644 index 00000000..1efb1da2 --- /dev/null +++ b/man/minor_breaks_log.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/breaks-log.R +\name{minor_breaks_log} +\alias{minor_breaks_log} +\title{Minor breaks for log-10 axes} +\usage{ +minor_breaks_log(detail = NULL, smallest = NULL) +} +\arguments{ +\item{detail}{Any of \code{1}, \code{5} and \code{10} to mark multiples of +powers, multiples of 5 of powers or just powers respectively.} + +\item{smallest}{Smallest absolute value to mark when the range includes +negative numbers.} +} +\value{ +A function to generate minor ticks. +} +\description{ +This break function is designed to mark every power, multiples of 5 and/or 1 +of that power for base 10. +} +\examples{ +# Standard usage with log10 scale +demo_log10(c(1, 1e10), minor_breaks = minor_breaks_log()) +# Increasing detail over many powers +demo_log10(c(1, 1e10), minor_breaks = minor_breaks_log(detail = 1)) +# Adjusting until where to draw minor breaks +demo_continuous( + c(-1000, 1000), + transform = asinh_trans(), + minor_breaks = minor_breaks_log(smallest = 1) +) +}