scales/ 0000755 0001762 0000144 00000000000 14531327156 011533 5 ustar ligges users scales/NAMESPACE 0000644 0001762 0000144 00000011705 14523373730 012756 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(fullseq,Date)
S3method(fullseq,POSIXt)
S3method(fullseq,difftime)
S3method(fullseq,numeric)
S3method(lines,transform)
S3method(offset_by,Date)
S3method(offset_by,POSIXt)
S3method(offset_by,difftime)
S3method(offset_by,numeric)
S3method(plot,transform)
S3method(print,transform)
S3method(rescale,"NULL")
S3method(rescale,AsIs)
S3method(rescale,Date)
S3method(rescale,POSIXt)
S3method(rescale,difftime)
S3method(rescale,dist)
S3method(rescale,integer64)
S3method(rescale,logical)
S3method(rescale,numeric)
S3method(rescale_mid,"NULL")
S3method(rescale_mid,AsIs)
S3method(rescale_mid,Date)
S3method(rescale_mid,POSIXt)
S3method(rescale_mid,dist)
S3method(rescale_mid,integer64)
S3method(rescale_mid,logical)
S3method(rescale_mid,numeric)
S3method(round_any,POSIXct)
S3method(round_any,numeric)
export(ContinuousRange)
export(DiscreteRange)
export(Range)
export(abs_area)
export(alpha)
export(area_pal)
export(as.trans)
export(as.transform)
export(asinh_trans)
export(asn_trans)
export(atanh_trans)
export(boxcox_trans)
export(breaks_extended)
export(breaks_log)
export(breaks_pretty)
export(breaks_timespan)
export(breaks_width)
export(brewer_pal)
export(cbreaks)
export(censor)
export(col2hcl)
export(col_bin)
export(col_factor)
export(col_numeric)
export(col_quantile)
export(colour_ramp)
export(comma)
export(comma_format)
export(compose_trans)
export(cscale)
export(cut_long_scale)
export(cut_short_scale)
export(cut_si)
export(cut_time_scale)
export(date_breaks)
export(date_format)
export(date_trans)
export(demo_continuous)
export(demo_datetime)
export(demo_discrete)
export(demo_log10)
export(demo_time)
export(demo_timespan)
export(dichromat_pal)
export(discard)
export(div_gradient_pal)
export(dollar)
export(dollar_format)
export(dscale)
export(exp_trans)
export(expand_range)
export(extended_breaks)
export(format_format)
export(fullseq)
export(gradient_n_pal)
export(grey_pal)
export(hms_trans)
export(hue_pal)
export(identity_pal)
export(identity_trans)
export(is.trans)
export(is.transform)
export(label_bytes)
export(label_comma)
export(label_currency)
export(label_date)
export(label_date_short)
export(label_dollar)
export(label_log)
export(label_math)
export(label_number)
export(label_number_auto)
export(label_number_si)
export(label_ordinal)
export(label_parse)
export(label_percent)
export(label_pvalue)
export(label_scientific)
export(label_time)
export(label_timespan)
export(label_wrap)
export(linetype_pal)
export(log10_trans)
export(log1p_trans)
export(log2_trans)
export(log_breaks)
export(log_trans)
export(logit_trans)
export(manual_pal)
export(math_format)
export(minor_breaks_n)
export(minor_breaks_width)
export(modulus_trans)
export(muted)
export(new_transform)
export(number)
export(number_bytes)
export(number_bytes_format)
export(number_format)
export(oob_censor)
export(oob_censor_any)
export(oob_discard)
export(oob_keep)
export(oob_squish)
export(oob_squish_any)
export(oob_squish_infinite)
export(ordinal)
export(ordinal_english)
export(ordinal_format)
export(ordinal_french)
export(ordinal_spanish)
export(pal_area)
export(pal_brewer)
export(pal_dichromat)
export(pal_div_gradient)
export(pal_gradient_n)
export(pal_grey)
export(pal_hue)
export(pal_identity)
export(pal_linetype)
export(pal_manual)
export(pal_rescale)
export(pal_seq_gradient)
export(pal_shape)
export(pal_viridis)
export(parse_format)
export(percent)
export(percent_format)
export(pretty_breaks)
export(probability_trans)
export(probit_trans)
export(pseudo_log_trans)
export(pvalue)
export(pvalue_format)
export(reciprocal_trans)
export(regular_minor_breaks)
export(rescale)
export(rescale_max)
export(rescale_mid)
export(rescale_none)
export(rescale_pal)
export(reverse_trans)
export(scientific)
export(scientific_format)
export(seq_gradient_pal)
export(shape_pal)
export(show_col)
export(sqrt_trans)
export(squish)
export(squish_infinite)
export(time_format)
export(time_trans)
export(timespan_trans)
export(train_continuous)
export(train_discrete)
export(trans_breaks)
export(trans_format)
export(trans_new)
export(trans_range)
export(transform_asinh)
export(transform_asn)
export(transform_atanh)
export(transform_boxcox)
export(transform_compose)
export(transform_date)
export(transform_exp)
export(transform_hms)
export(transform_identity)
export(transform_log)
export(transform_log10)
export(transform_log1p)
export(transform_log2)
export(transform_logit)
export(transform_modulus)
export(transform_probability)
export(transform_probit)
export(transform_pseudo_log)
export(transform_reciprocal)
export(transform_reverse)
export(transform_sqrt)
export(transform_time)
export(transform_timespan)
export(transform_yj)
export(trim_to_domain)
export(unit_format)
export(viridis_pal)
export(wrap_format)
export(yj_trans)
export(zero_range)
import(rlang)
importFrom(R6,R6Class)
importFrom(glue,glue)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,rect)
importFrom(graphics,text)
importFrom(lifecycle,deprecate_soft)
importFrom(lifecycle,deprecated)
importFrom(munsell,mnsl)
scales/LICENSE 0000644 0001762 0000144 00000000054 14520132374 012531 0 ustar ligges users YEAR: 2023
COPYRIGHT HOLDER: scales authors
scales/README.md 0000644 0001762 0000144 00000007555 14531055367 013030 0 ustar ligges users
# scales
[](https://CRAN.R-project.org/package=scales)
[](https://github.com/r-lib/scales/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/r-lib/scales?branch=main)
One of the most difficult parts of any graphics package is scaling,
converting from data values to perceptual properties. The inverse of
scaling, making guides (legends and axes) that can be used to read the
graph, is often even harder! The scales packages provides the internal
scaling infrastructure used by
[ggplot2](https://ggplot2.tidyverse.org/), and gives you tools to
override the default breaks, labels, transformations and palettes.
## Installation
``` r
# Scales is installed when you install ggplot2 or the tidyverse.
# But you can install just scales from CRAN:
install.packages("scales")
# Or the development version from Github:
# install.packages("pak")
pak::pak("r-lib/scales")
```
## Usage
### Breaks and labels
The most common use of the scales package is to control the appearance
of axis and legend labels. Use a `break_` function to control how breaks
are generated from the limits, and a `label_` function to control how
breaks are turned in to labels.
``` r
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(lubridate, warn.conflicts = FALSE)
txhousing %>%
mutate(date = make_date(year, month, 1)) %>%
group_by(city) %>%
filter(min(sales) > 5e2) %>%
ggplot(aes(date, sales, group = city)) +
geom_line(na.rm = TRUE) +
scale_x_date(
NULL,
breaks = scales::breaks_width("2 years"),
labels = scales::label_date("'%y")
) +
scale_y_log10(
"Total sales",
labels = scales::label_number(scale_cut = scales::cut_short_scale())
)
```

``` r
economics %>%
filter(date < ymd("1970-01-01")) %>%
ggplot(aes(date, pce)) +
geom_line() +
scale_x_date(NULL,
breaks = scales::breaks_width("3 months"),
labels = scales::label_date_short()
) +
scale_y_continuous("Personal consumption expenditures",
breaks = scales::breaks_extended(8),
labels = scales::label_dollar()
)
```

Generally, I don’t recommend running `library(scales)` because when you
type (e.g.) `scales::label_` autocomplete will provide you with a list
of labelling functions to jog your memory.
### Advanced features
Scales colour palettes are used to power the scales in ggplot2, but you
can use them in any plotting system. The following example shows how you
might apply them to a base plot.
``` r
library(scales)
# pull a list of colours from any palette
pal_viridis()(4)
#> [1] "#440154FF" "#31688EFF" "#35B779FF" "#FDE725FF"
# use in combination with baseR `palette()` to set new defaults
palette(pal_brewer(palette = "Set2")(4))
par(mar = c(5, 5, 1, 1))
plot(Sepal.Length ~ Sepal.Width, data = iris, col = Species, pch = 20)
```

scales also gives users the ability to define and apply their own custom
transformation functions for repeated use.
``` r
# use new_transform to build a new transformation
transform_logp3 <- new_transform(
name = "logp",
transform = function(x) log(x + 3),
inverse = function(x) exp(x) - 3,
breaks = log_breaks()
)
dsamp <- sample_n(diamonds, 100)
ggplot(dsamp, aes(carat, price, colour = color)) +
geom_point() +
scale_y_continuous(trans = transform_logp3)
```

scales/man/ 0000755 0001762 0000144 00000000000 14522421001 012266 5 ustar ligges users scales/man/pal_manual.Rd 0000644 0001762 0000144 00000000527 14522421001 014672 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-manual.R
\name{pal_manual}
\alias{pal_manual}
\alias{manual_pal}
\title{Manual palette (discrete)}
\usage{
pal_manual(values)
manual_pal(values)
}
\arguments{
\item{values}{vector of values to be used as a palette.}
}
\description{
Manual palette (discrete)
}
scales/man/unit_format.Rd 0000644 0001762 0000144 00000004243 14520130030 015104 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/labels-retired.R
\name{unit_format}
\alias{unit_format}
\title{Unit labels}
\usage{
unit_format(
accuracy = NULL,
scale = 1,
prefix = "",
unit = "m",
sep = " ",
suffix = paste0(sep, unit),
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
}
\arguments{
\item{accuracy}{A number to round to. Use (e.g.) \code{0.01} to show 2 decimal
places of precision. If \code{NULL}, the default, uses a heuristic that should
ensure breaks have the minimum number of digits needed to show the
difference between adjacent values.
Applied to rescaled data.}
\item{scale}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{prefix}{Additional text to display before the number. The suffix is
applied to absolute value before \code{style_positive} and \code{style_negative} are
processed so that \code{prefix = "$"} will yield (e.g.) \verb{-$1} and \verb{($1)}.}
\item{unit}{The units to append.}
\item{sep}{The separator between the number and the unit label.}
\item{suffix}{Additional text to display after the number.}
\item{big.mark}{Character used between every 3 digits to separate thousands.}
\item{decimal.mark}{The character to be used to indicate the numeric
decimal point.}
\item{trim}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
This function is kept for backward compatiblity; you should either use
\code{\link[=label_number]{label_number()}} or \code{\link[=label_number_si]{label_number_si()}} instead.
}
\examples{
# Label with units
demo_continuous(c(0, 1), labels = unit_format(unit = "m"))
# Labels in kg, but original data in g
km <- unit_format(unit = "km", scale = 1e-3, digits = 2)
demo_continuous(c(0, 2500), labels = km)
}
\keyword{internal}
scales/man/percent_format.Rd 0000644 0001762 0000144 00000003724 14520130030 015570 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-percent.R
\name{percent_format}
\alias{percent_format}
\alias{percent}
\title{Superseded interface to \code{label_percent()}}
\usage{
percent_format(
accuracy = NULL,
scale = 100,
prefix = "",
suffix = "\%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
percent(
x,
accuracy = NULL,
scale = 100,
prefix = "",
suffix = "\%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE,
...
)
}
\arguments{
\item{accuracy}{A number to round to. Use (e.g.) \code{0.01} to show 2 decimal
places of precision. If \code{NULL}, the default, uses a heuristic that should
ensure breaks have the minimum number of digits needed to show the
difference between adjacent values.
Applied to rescaled data.}
\item{scale}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{prefix}{Additional text to display before the number. The suffix is
applied to absolute value before \code{style_positive} and \code{style_negative} are
processed so that \code{prefix = "$"} will yield (e.g.) \verb{-$1} and \verb{($1)}.}
\item{suffix}{Additional text to display after the number.}
\item{big.mark}{Character used between every 3 digits to separate thousands.}
\item{decimal.mark}{The character to be used to indicate the numeric
decimal point.}
\item{trim}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
These functions are kept for backward compatibility; you should switch
to \code{\link[=label_percent]{label_percent()}} for new code.
}
\keyword{internal}
scales/man/fullseq.Rd 0000644 0001762 0000144 00000000653 14520145514 014246 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/full-seq.R
\name{fullseq}
\alias{fullseq}
\title{Generate sequence of fixed size intervals covering range.}
\usage{
fullseq(range, size, ...)
}
\arguments{
\item{range}{range}
\item{size}{interval size}
\item{...}{other arguments passed on to methods}
}
\description{
Generate sequence of fixed size intervals covering range.
}
\keyword{internal}
scales/man/transform_asn.Rd 0000644 0001762 0000144 00000000603 14522421001 015430 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_asn}
\alias{transform_asn}
\alias{asn_trans}
\title{Arc-sin square root transformation}
\usage{
transform_asn()
asn_trans()
}
\description{
This is the variance stabilising transformation for the binomial
distribution.
}
\examples{
plot(transform_asn(), xlim = c(0, 1))
}
scales/man/trans_breaks.Rd 0000644 0001762 0000144 00000001717 14520130030 015236 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/breaks-retired.R
\name{trans_breaks}
\alias{trans_breaks}
\title{Pretty breaks on transformed scale}
\usage{
trans_breaks(trans, inv, n = 5, ...)
}
\arguments{
\item{trans}{function of single variable, \code{x}, that given a numeric
vector returns the transformed values}
\item{inv}{inverse of the transformation function}
\item{n}{desired number of ticks}
\item{...}{other arguments passed on to pretty}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
These often do not produce very attractive breaks.
}
\examples{
trans_breaks("log10", function(x) 10^x)(c(1, 1e6))
trans_breaks("sqrt", function(x) x^2)(c(1, 100))
trans_breaks(function(x) 1 / x, function(x) 1 / x)(c(1, 100))
trans_breaks(function(x) -x, function(x) -x)(c(1, 100))
}
\keyword{internal}
scales/man/transform_probability.Rd 0000644 0001762 0000144 00000001703 14522421001 017171 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_probability}
\alias{transform_probability}
\alias{transform_logit}
\alias{transform_probit}
\alias{probability_trans}
\alias{logit_trans}
\alias{probit_trans}
\title{Probability transformation}
\usage{
transform_probability(distribution, ...)
transform_logit()
transform_probit()
probability_trans(distribution, ...)
logit_trans()
probit_trans()
}
\arguments{
\item{distribution}{probability distribution. Should be standard R
abbreviation so that "p" + distribution is a valid cumulative distribution
function, "q" + distribution is a valid quantile function, and
"d" + distribution is a valid probability density function.}
\item{...}{other arguments passed on to distribution and quantile functions}
}
\description{
Probability transformation
}
\examples{
plot(transform_logit(), xlim = c(0, 1))
plot(transform_probit(), xlim = c(0, 1))
}
scales/man/pal_div_gradient.Rd 0000644 0001762 0000144 00000002201 14522421001 016043 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-gradient.R
\name{pal_div_gradient}
\alias{pal_div_gradient}
\alias{div_gradient_pal}
\title{Diverging colour gradient (continuous).}
\usage{
pal_div_gradient(
low = mnsl("10B 4/6"),
mid = mnsl("N 8/0"),
high = mnsl("10R 4/6"),
space = "Lab"
)
div_gradient_pal(
low = mnsl("10B 4/6"),
mid = mnsl("N 8/0"),
high = mnsl("10R 4/6"),
space = "Lab"
)
}
\arguments{
\item{low}{colour for low end of gradient.}
\item{mid}{colour for mid point}
\item{high}{colour for high end of gradient.}
\item{space}{colour space in which to calculate gradient. Must be "Lab" -
other values are deprecated.}
}
\description{
Diverging colour gradient (continuous).
}
\examples{
x <- seq(-1, 1, length.out = 100)
r <- sqrt(outer(x^2, x^2, "+"))
image(r, col = pal_div_gradient()(seq(0, 1, length.out = 12)))
image(r, col = pal_div_gradient()(seq(0, 1, length.out = 30)))
image(r, col = pal_div_gradient()(seq(0, 1, length.out = 100)))
library(munsell)
pal <- pal_div_gradient(low = mnsl(complement("10R 4/6"), fix = TRUE))
image(r, col = pal(seq(0, 1, length.out = 100)))
}
scales/man/pal_area.Rd 0000644 0001762 0000144 00000000741 14522421001 014323 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-area.R
\name{pal_area}
\alias{pal_area}
\alias{area_pal}
\alias{abs_area}
\title{Area palettes (continuous)}
\usage{
pal_area(range = c(1, 6))
area_pal(range = c(1, 6))
abs_area(max)
}
\arguments{
\item{range}{Numeric vector of length two, giving range of possible sizes.
Should be greater than 0.}
\item{max}{A number representing the maximum size.}
}
\description{
Area palettes (continuous)
}
scales/man/label_ordinal.Rd 0000644 0001762 0000144 00000011517 14523373730 015371 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-ordinal.R
\name{label_ordinal}
\alias{label_ordinal}
\alias{ordinal_english}
\alias{ordinal_french}
\alias{ordinal_spanish}
\title{Label ordinal numbers (1st, 2nd, 3rd, etc)}
\usage{
label_ordinal(
prefix = "",
suffix = "",
big.mark = " ",
rules = ordinal_english(),
...
)
ordinal_english()
ordinal_french(gender = c("masculin", "feminin"), plural = FALSE)
ordinal_spanish()
}
\arguments{
\item{prefix, suffix}{Symbols to display before and after value.}
\item{big.mark}{Character used between every 3 digits to separate thousands.}
\item{rules}{Named list of regular expressions, matched in order.
Name gives suffix, and value specifies which numbers to match.}
\item{...}{
Arguments passed on to \code{\link[=number]{number}}
\describe{
\item{\code{accuracy}}{A number to round to. Use (e.g.) \code{0.01} to show 2 decimal
places of precision. If \code{NULL}, the default, uses a heuristic that should
ensure breaks have the minimum number of digits needed to show the
difference between adjacent values.
Applied to rescaled data.}
\item{\code{scale}}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{\code{decimal.mark}}{The character to be used to indicate the numeric
decimal point.}
\item{\code{style_positive}}{A string that determines the style of positive numbers:
\itemize{
\item \code{"none"} (the default): no change, e.g. \code{1}.
\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}.
\item \code{"space"}: preceded by a Unicode "figure space", i.e., a space equally
as wide as a number or \code{+}. Compared to \code{"none"}, adding a figure space
can ensure numbers remain properly aligned when they are left- or
right-justified.
}}
\item{\code{style_negative}}{A string that determines the style of negative numbers:
\itemize{
\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}.
\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical
nicety that ensures \code{-} aligns with the horizontal bar of the
the horizontal bar of \code{+}.
\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}.
}}
\item{\code{scale_cut}}{Named numeric vector that allows you to rescale large
(or small) numbers and add a prefix. Built-in helpers include:
\itemize{
\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T.
\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T.
\item \code{cut_si(unit)}: uses standard SI units.
}
If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the
range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)}
will be divided by 100 and given the suffix "a", and absolute values in
the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".
If the division creates an irrational value (or one with many digits), the
cut value below will be tried to see if it improves the look of the final
label.}
\item{\code{trim}}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
}}
\item{gender}{Masculin or feminin gender for French ordinal.}
\item{plural}{Plural or singular for French ordinal.}
}
\value{
All \code{label_()} functions return a "labelling" function, i.e. a function that
takes a vector \code{x} and returns a character vector of \code{length(x)} giving a
label for each input value.
Labelling functions are designed to be used with the \code{labels} argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
}
\description{
Round values to integers and then display as ordinal values (e.g. 1st, 2nd,
3rd). Built-in rules are provided for English, French, and Spanish.
}
\examples{
demo_continuous(c(1, 5))
demo_continuous(c(1, 5), labels = label_ordinal())
demo_continuous(c(1, 5), labels = label_ordinal(rules = ordinal_french()))
# The rules are just a set of regular expressions that are applied in turn
ordinal_french()
ordinal_english()
# Note that ordinal rounds values, so you may need to adjust the breaks too
demo_continuous(c(1, 10))
demo_continuous(c(1, 10), labels = label_ordinal())
demo_continuous(c(1, 10),
labels = label_ordinal(),
breaks = breaks_width(2)
)
}
\seealso{
Other labels for continuous scales:
\code{\link{label_bytes}()},
\code{\link{label_currency}()},
\code{\link{label_number_auto}()},
\code{\link{label_number_si}()},
\code{\link{label_parse}()},
\code{\link{label_percent}()},
\code{\link{label_pvalue}()},
\code{\link{label_scientific}()}
}
\concept{labels for continuous scales}
scales/man/transform_identity.Rd 0000644 0001762 0000144 00000000572 14522421001 016505 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_identity}
\alias{transform_identity}
\alias{identity_trans}
\title{Identity transformation (do nothing)}
\usage{
transform_identity()
identity_trans()
}
\description{
Identity transformation (do nothing)
}
\examples{
plot(transform_identity(), xlim = c(-1, 1))
}
scales/man/scientific_format.Rd 0000644 0001762 0000144 00000002623 14520130030 016245 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-scientific.R
\name{scientific_format}
\alias{scientific_format}
\alias{scientific}
\title{Superseded interface to \code{label_scientific()}}
\usage{
scientific_format(
digits = 3,
scale = 1,
prefix = "",
suffix = "",
decimal.mark = ".",
trim = TRUE,
...
)
scientific(
x,
digits = 3,
scale = 1,
prefix = "",
suffix = "",
decimal.mark = ".",
trim = TRUE,
...
)
}
\arguments{
\item{digits}{Number of digits to show before exponent.}
\item{scale}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{prefix, suffix}{Symbols to display before and after value.}
\item{decimal.mark}{The character to be used to indicate the numeric
decimal point.}
\item{trim}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
These functions are kept for backward compatibility; you should switch
to \code{\link[=label_scientific]{label_scientific()}} for new code.
}
\keyword{internal}
scales/man/transform_timespan.Rd 0000644 0001762 0000144 00000002546 14522421001 016477 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-date.R
\name{transform_timespan}
\alias{transform_timespan}
\alias{timespan_trans}
\alias{transform_hms}
\alias{hms_trans}
\title{Transformation for times (class hms)}
\usage{
transform_timespan(unit = c("secs", "mins", "hours", "days", "weeks"))
timespan_trans(unit = c("secs", "mins", "hours", "days", "weeks"))
transform_hms()
hms_trans()
}
\arguments{
\item{unit}{The unit used to interpret numeric input}
}
\description{
\code{transform_timespan()} provides transformations for data encoding time passed
along with breaks and label formatting showing standard unit of time fitting
the range of the data. \code{transform_hms()} provides the same but using standard
hms idioms and formatting.
}
\examples{
# transform_timespan allows you to specify the time unit numeric data is
# interpreted in
trans_min <- transform_timespan("mins")
demo_timespan(seq(0, 100), trans = trans_min)
# Input already in difftime format is interpreted correctly
demo_timespan(as.difftime(seq(0, 100), units = "secs"), trans = trans_min)
if (require("hms")) {
# transform_hms always assumes seconds
hms <- round(runif(10) * 86400)
t <- transform_hms()
t$transform(hms)
t$inverse(t$transform(hms))
t$breaks(hms)
# The break labels also follow the hms format
demo_timespan(hms, trans = t)
}
}
scales/man/pal_linetype.Rd 0000644 0001762 0000144 00000000476 14522421001 015251 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-linetype.R
\name{pal_linetype}
\alias{pal_linetype}
\alias{linetype_pal}
\title{Line type palette (discrete)}
\usage{
pal_linetype()
linetype_pal()
}
\description{
Based on a set supplied by Richard Pearson, University of Manchester
}
scales/man/minor_breaks_width.Rd 0000644 0001762 0000144 00000002640 14520130030 016426 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/minor_breaks.R
\name{minor_breaks_width}
\alias{minor_breaks_width}
\alias{minor_breaks_n}
\title{Minor breaks}
\usage{
minor_breaks_width(width, offset)
minor_breaks_n(n)
}
\arguments{
\item{width}{Distance between each break. Either a number, or for
date/times, a single string of the form \code{"{n} {unit}"}, e.g. "1 month",
"5 days". Unit can be of one "sec", "min", "hour", "day", "week",
"month", "year".}
\item{offset}{Use if you don't want breaks to start at zero, or on a
conventional date or time boundary such as the 1st of January or midnight.
Either a number, or for date/times, a single string of the form
\code{"{n} {unit}"}, as for \code{width}.
\code{offset} can be a vector, which will accumulate in the order given. This
is mostly useful for dates, where e.g. \code{c("3 months", "5 days")} will
offset by three months and five days, which is useful for the UK tax year.
Note that due to way that dates are rounded, there's no guarantee that
\code{offset = c(x, y)} will give the same result as \code{offset = c(y, x)}.}
\item{n}{number of breaks}
}
\description{
Generate minor breaks between major breaks either spaced with a fixed width,
or having a fixed number.
}
\examples{
demo_log10(c(1, 1e6))
if (FALSE) {
# Requires https://github.com/tidyverse/ggplot2/pull/3591
demo_log10(c(1, 1e6), minor_breaks = minor_breaks_n(10))
}
}
scales/man/label_scientific.Rd 0000644 0001762 0000144 00000004136 14522154141 016050 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-scientific.R
\name{label_scientific}
\alias{label_scientific}
\title{Label numbers with scientific notation (e.g. 1e05, 1.5e-02)}
\usage{
label_scientific(
digits = 3,
scale = 1,
prefix = "",
suffix = "",
decimal.mark = ".",
trim = TRUE,
...
)
}
\arguments{
\item{digits}{Number of digits to show before exponent.}
\item{scale}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{prefix, suffix}{Symbols to display before and after value.}
\item{decimal.mark}{The character to be used to indicate the numeric
decimal point.}
\item{trim}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.}
}
\value{
All \code{label_()} functions return a "labelling" function, i.e. a function that
takes a vector \code{x} and returns a character vector of \code{length(x)} giving a
label for each input value.
Labelling functions are designed to be used with the \code{labels} argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
}
\description{
Label numbers with scientific notation (e.g. 1e05, 1.5e-02)
}
\examples{
demo_continuous(c(1, 10))
demo_continuous(c(1, 10), labels = label_scientific())
demo_continuous(c(1, 10), labels = label_scientific(digits = 3))
demo_log10(c(1, 1e9))
}
\seealso{
Other labels for continuous scales:
\code{\link{label_bytes}()},
\code{\link{label_currency}()},
\code{\link{label_number_auto}()},
\code{\link{label_number_si}()},
\code{\link{label_ordinal}()},
\code{\link{label_parse}()},
\code{\link{label_percent}()},
\code{\link{label_pvalue}()}
Other labels for log scales:
\code{\link{label_bytes}()},
\code{\link{label_log}()},
\code{\link{label_number_si}()}
}
\concept{labels for continuous scales}
\concept{labels for log scales}
scales/man/pal_rescale.Rd 0000644 0001762 0000144 00000000764 14522421001 015036 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-rescale.R
\name{pal_rescale}
\alias{pal_rescale}
\alias{rescale_pal}
\title{Rescale palette (continuous)}
\usage{
pal_rescale(range = c(0.1, 1))
rescale_pal(range = c(0.1, 1))
}
\arguments{
\item{range}{Numeric vector of length two, giving range of possible
values. Should be between 0 and 1.}
}
\description{
Just rescales the input to the specific output range. Useful for
alpha, size, and continuous position.
}
scales/man/transform_atanh.Rd 0000644 0001762 0000144 00000000524 14522421001 015744 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_atanh}
\alias{transform_atanh}
\alias{atanh_trans}
\title{Arc-tangent transformation}
\usage{
transform_atanh()
atanh_trans()
}
\description{
Arc-tangent transformation
}
\examples{
plot(transform_atanh(), xlim = c(-1, 1))
}
scales/man/number.Rd 0000644 0001762 0000144 00000007501 14523373730 014070 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-number.R
\name{number}
\alias{number}
\alias{cut_short_scale}
\alias{cut_long_scale}
\alias{cut_time_scale}
\alias{cut_si}
\title{A low-level numeric formatter}
\usage{
number(
x,
accuracy = NULL,
scale = 1,
prefix = "",
suffix = "",
big.mark = " ",
decimal.mark = ".",
style_positive = c("none", "plus", "space"),
style_negative = c("hyphen", "minus", "parens"),
scale_cut = NULL,
trim = TRUE,
...
)
cut_short_scale(space = FALSE)
cut_long_scale(space = FALSE)
cut_time_scale(space = FALSE)
cut_si(unit)
}
\arguments{
\item{accuracy}{A number to round to. Use (e.g.) \code{0.01} to show 2 decimal
places of precision. If \code{NULL}, the default, uses a heuristic that should
ensure breaks have the minimum number of digits needed to show the
difference between adjacent values.
Applied to rescaled data.}
\item{scale}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{prefix}{Additional text to display before the number. The suffix is
applied to absolute value before \code{style_positive} and \code{style_negative} are
processed so that \code{prefix = "$"} will yield (e.g.) \verb{-$1} and \verb{($1)}.}
\item{suffix}{Additional text to display after the number.}
\item{big.mark}{Character used between every 3 digits to separate thousands.}
\item{decimal.mark}{The character to be used to indicate the numeric
decimal point.}
\item{style_positive}{A string that determines the style of positive numbers:
\itemize{
\item \code{"none"} (the default): no change, e.g. \code{1}.
\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}.
\item \code{"space"}: preceded by a Unicode "figure space", i.e., a space equally
as wide as a number or \code{+}. Compared to \code{"none"}, adding a figure space
can ensure numbers remain properly aligned when they are left- or
right-justified.
}}
\item{style_negative}{A string that determines the style of negative numbers:
\itemize{
\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}.
\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical
nicety that ensures \code{-} aligns with the horizontal bar of the
the horizontal bar of \code{+}.
\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}.
}}
\item{scale_cut}{Named numeric vector that allows you to rescale large
(or small) numbers and add a prefix. Built-in helpers include:
\itemize{
\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T.
\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T.
\item \code{cut_si(unit)}: uses standard SI units.
}
If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the
range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)}
will be divided by 100 and given the suffix "a", and absolute values in
the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".
If the division creates an irrational value (or one with many digits), the
cut value below will be tried to see if it improves the look of the final
label.}
\item{trim}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.}
\item{space}{Add a space before the scale suffix?}
\item{unit}{SI unit abbreviation.}
}
\value{
A character vector of \code{length(x)}.
}
\description{
This function is a low-level helper that powers many of the labelling
functions. You should generally not need to call it directly unless you
are creating your own labelling function.
}
\keyword{internal}
scales/man/label_log.Rd 0000644 0001762 0000144 00000002477 14520130030 014504 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-log.R
\name{label_log}
\alias{label_log}
\title{Label numbers in log format (10^3, 10^6, etc)}
\usage{
label_log(base = 10, digits = 3)
}
\arguments{
\item{base}{Base of logarithm to use}
\item{digits}{Number of significant digits to show for the exponent. Argument
is passed on to \code{\link[base:format]{base::format()}}.}
}
\value{
All \code{label_()} functions return a "labelling" function, i.e. a function that
takes a vector \code{x} and returns a character vector of \code{length(x)} giving a
label for each input value.
Labelling functions are designed to be used with the \code{labels} argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
}
\description{
\code{label_log()} displays numbers as base^exponent, using superscript formatting.
}
\examples{
demo_log10(c(1, 1e5), labels = label_log())
demo_log10(c(1, 1e5), breaks = breaks_log(base = 2), labels = label_log(base = 2))
}
\seealso{
\code{\link[=breaks_log]{breaks_log()}} for the related breaks algorithm.
Other labels for log scales:
\code{\link{label_bytes}()},
\code{\link{label_number_si}()},
\code{\link{label_scientific}()}
}
\concept{labels for log scales}
scales/man/label_date.Rd 0000644 0001762 0000144 00000012617 14531113322 014644 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-date.R
\name{label_date}
\alias{label_date}
\alias{label_date_short}
\alias{label_time}
\alias{label_timespan}
\title{Label date/times}
\usage{
label_date(format = "\%Y-\%m-\%d", tz = "UTC", locale = NULL)
label_date_short(format = c("\%Y", "\%b", "\%d", "\%H:\%M"), sep = "\\n")
label_time(format = "\%H:\%M:\%S", tz = "UTC", locale = NULL)
label_timespan(
unit = c("secs", "mins", "hours", "days", "weeks"),
space = FALSE,
...
)
}
\arguments{
\item{format}{For \code{date_format()} and \code{time_format()} a date/time format
string using standard POSIX specification. See \code{\link[=strptime]{strptime()}} for details.
For \code{date_short()} a character vector of length 4 giving the format
components to use for year, month, day, and hour respectively.}
\item{tz}{a time zone name, see \code{\link[=timezones]{timezones()}}. Defaults
to UTC}
\item{locale}{Locale to use when for day and month names. The default
uses the current locale. Setting this argument requires stringi, and you
can see a complete list of supported locales with
\code{\link[stringi:stri_locale_list]{stringi::stri_locale_list()}}.}
\item{sep}{Separator to use when combining date formats into a single string.}
\item{unit}{The unit used to interpret numeric input}
\item{space}{Add a space before the time unit?}
\item{...}{
Arguments passed on to \code{\link[=number]{number}}
\describe{
\item{\code{accuracy}}{A number to round to. Use (e.g.) \code{0.01} to show 2 decimal
places of precision. If \code{NULL}, the default, uses a heuristic that should
ensure breaks have the minimum number of digits needed to show the
difference between adjacent values.
Applied to rescaled data.}
\item{\code{scale}}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{\code{prefix}}{Additional text to display before the number. The suffix is
applied to absolute value before \code{style_positive} and \code{style_negative} are
processed so that \code{prefix = "$"} will yield (e.g.) \verb{-$1} and \verb{($1)}.}
\item{\code{suffix}}{Additional text to display after the number.}
\item{\code{big.mark}}{Character used between every 3 digits to separate thousands.}
\item{\code{decimal.mark}}{The character to be used to indicate the numeric
decimal point.}
\item{\code{style_positive}}{A string that determines the style of positive numbers:
\itemize{
\item \code{"none"} (the default): no change, e.g. \code{1}.
\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}.
\item \code{"space"}: preceded by a Unicode "figure space", i.e., a space equally
as wide as a number or \code{+}. Compared to \code{"none"}, adding a figure space
can ensure numbers remain properly aligned when they are left- or
right-justified.
}}
\item{\code{style_negative}}{A string that determines the style of negative numbers:
\itemize{
\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}.
\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical
nicety that ensures \code{-} aligns with the horizontal bar of the
the horizontal bar of \code{+}.
\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}.
}}
\item{\code{trim}}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
}}
}
\value{
All \code{label_()} functions return a "labelling" function, i.e. a function that
takes a vector \code{x} and returns a character vector of \code{length(x)} giving a
label for each input value.
Labelling functions are designed to be used with the \code{labels} argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
}
\description{
\code{label_date()} and \code{label_time()} label date/times using date/time format
strings. \code{label_date_short()} automatically constructs a short format string
sufficient to uniquely identify labels. It's inspired by matplotlib's
\href{https://matplotlib.org/stable/api/dates_api.html#matplotlib.dates.ConciseDateFormatter}{\code{ConciseDateFormatter}},
but uses a slightly different approach: \code{ConciseDateFormatter} formats
"firsts" (e.g. first day of month, first day of day) specially;
\code{date_short()} formats changes (e.g. new month, new year) specially.
\code{label_timespan()} is intended to show time passed and adds common time units
suffix to the input (ns, us, ms, s, m, h, d, w).
}
\examples{
date_range <- function(start, days) {
start <- as.POSIXct(start)
c(start, start + days * 24 * 60 * 60)
}
two_months <- date_range("2020-05-01", 60)
demo_datetime(two_months)
demo_datetime(two_months, labels = date_format("\%m/\%d"))
demo_datetime(two_months, labels = date_format("\%e \%b", locale = "fr"))
demo_datetime(two_months, labels = date_format("\%e \%B", locale = "es"))
# ggplot2 provides a short-hand:
demo_datetime(two_months, date_labels = "\%m/\%d")
# An alternative labelling system is label_date_short()
demo_datetime(two_months, date_breaks = "7 days", labels = label_date_short())
# This is particularly effective for dense labels
one_year <- date_range("2020-05-01", 365)
demo_datetime(one_year, date_breaks = "month")
demo_datetime(one_year, date_breaks = "month", labels = label_date_short())
}
scales/man/colour_ramp.Rd 0000644 0001762 0000144 00000003747 13610067251 015124 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colour-ramp.R
\name{colour_ramp}
\alias{colour_ramp}
\title{Fast colour interpolation}
\usage{
colour_ramp(colors, na.color = NA, alpha = TRUE)
}
\arguments{
\item{colors}{Colours to interpolate; must be a valid argument to
\code{\link[grDevices:col2rgb]{grDevices::col2rgb()}}. This can be a character vector of
\code{"#RRGGBB"} or \code{"#RRGGBBAA"}, colour names from
\code{\link[grDevices:colors]{grDevices::colors()}}, or a positive integer that indexes into
\code{\link[grDevices:palette]{grDevices::palette()}}.}
\item{na.color}{The colour to map to \code{NA} values (for example,
\code{"#606060"} for dark grey, or \code{"#00000000"} for transparent) and
values outside of [0,1]. Can itself by \code{NA}, which will simply cause
an \code{NA} to be inserted into the output.}
\item{alpha}{Whether to include alpha transparency channels in interpolation.
If \code{TRUE} then the alpha information is included in the interpolation.
The returned colours will be provided in \code{"#RRGGBBAA"} format when needed,
i.e., in cases where the colour is not fully opaque, so that the \code{"AA"}
part is not equal to \code{"FF"}. Fully opaque colours will be returned in
\code{"#RRGGBB"} format. If \code{FALSE}, the alpha information is discarded
before interpolation and colours are always returned as \code{"#RRGGBB"}.}
}
\value{
A function that takes a numeric vector and returns a character vector
of the same length with RGB or RGBA hex colours.
}
\description{
Returns a function that maps the interval [0,1] to a set of colours.
Interpolation is performed in the CIELAB colour space. Similar to
\code{\link[grDevices]{colorRamp}(space = 'Lab')}, but hundreds of
times faster, and provides results in \code{"#RRGGBB"} (or
\code{"#RRGGBBAA"}) character form instead of RGB colour matrices.
}
\examples{
ramp <- colour_ramp(c("red", "green", "blue"))
show_col(ramp(seq(0, 1, length = 12)))
}
\seealso{
\code{\link[grDevices]{colorRamp}}
}
scales/man/alpha.Rd 0000644 0001762 0000144 00000001050 14520145514 013650 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colour-manip.R
\name{alpha}
\alias{alpha}
\title{Modify colour transparency}
\usage{
alpha(colour, alpha = NA)
}
\arguments{
\item{colour}{colour}
\item{alpha}{new alpha level in [0,1]. If alpha is \code{NA},
existing alpha values are preserved.}
}
\description{
Vectorised in both colour and alpha.
}
\examples{
alpha("red", 0.1)
alpha(colours(), 0.5)
alpha("red", seq(0, 1, length.out = 10))
alpha(c("first" = "gold", "second" = "lightgray", "third" = "#cd7f32"), .5)
}
scales/man/pal_hue.Rd 0000644 0001762 0000144 00000002152 14522421001 014172 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-hue.R
\name{pal_hue}
\alias{pal_hue}
\alias{hue_pal}
\title{Hue palette (discrete)}
\usage{
pal_hue(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1)
hue_pal(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1)
}
\arguments{
\item{h}{range of hues to use, in [0, 360]}
\item{c}{chroma (intensity of colour), maximum value varies depending on
combination of hue and luminance.}
\item{l}{luminance (lightness), in [0, 100]}
\item{h.start}{hue to start at}
\item{direction}{direction to travel around the colour wheel,
1 = clockwise, -1 = counter-clockwise}
}
\description{
Hue palette (discrete)
}
\examples{
show_col(pal_hue()(4))
show_col(pal_hue()(9))
show_col(pal_hue(l = 90)(9))
show_col(pal_hue(l = 30)(9))
show_col(pal_hue()(9))
show_col(pal_hue(direction = -1)(9))
show_col(pal_hue(h.start = 30)(9))
show_col(pal_hue(h.start = 90)(9))
show_col(pal_hue()(9))
show_col(pal_hue(h = c(0, 90))(9))
show_col(pal_hue(h = c(90, 180))(9))
show_col(pal_hue(h = c(180, 270))(9))
show_col(pal_hue(h = c(270, 360))(9))
}
scales/man/transform_date.Rd 0000644 0001762 0000144 00000000741 14522421001 015567 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-date.R
\name{transform_date}
\alias{transform_date}
\alias{date_trans}
\title{Transformation for dates (class Date)}
\usage{
transform_date()
date_trans()
}
\description{
Transformation for dates (class Date)
}
\examples{
years <- seq(as.Date("1910/1/1"), as.Date("1999/1/1"), "years")
t <- transform_date()
t$transform(years)
t$inverse(t$transform(years))
t$format(t$breaks(range(years)))
}
scales/man/pretty_breaks.Rd 0000644 0001762 0000144 00000001346 14520145514 015451 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/breaks.R
\name{pretty_breaks}
\alias{pretty_breaks}
\title{Superseded interface to \code{breaks_pretty()}}
\usage{
pretty_breaks(n = 5, ...)
}
\arguments{
\item{n}{Desired number of breaks. You may get slightly more or fewer
breaks that requested.}
\item{...}{other arguments passed on to \code{\link[=pretty]{pretty()}}}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
These functions are kept for backward compatibility; you should switch
to \code{\link[=breaks_pretty]{breaks_pretty()}} for new code.
}
\keyword{internal}
scales/man/col_numeric.Rd 0000644 0001762 0000144 00000012575 14520145514 015100 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colour-mapping.R
\name{col_numeric}
\alias{col_numeric}
\alias{col_bin}
\alias{col_quantile}
\alias{col_factor}
\title{Colour mapping}
\usage{
col_numeric(
palette,
domain,
na.color = "#808080",
alpha = FALSE,
reverse = FALSE
)
col_bin(
palette,
domain,
bins = 7,
pretty = TRUE,
na.color = "#808080",
alpha = FALSE,
reverse = FALSE,
right = FALSE
)
col_quantile(
palette,
domain,
n = 4,
probs = seq(0, 1, length.out = n + 1),
na.color = "#808080",
alpha = FALSE,
reverse = FALSE,
right = FALSE
)
col_factor(
palette,
domain,
levels = NULL,
ordered = FALSE,
na.color = "#808080",
alpha = FALSE,
reverse = FALSE
)
}
\arguments{
\item{palette}{The colours or colour function that values will be mapped to}
\item{domain}{The possible values that can be mapped.
For \code{col_numeric} and \code{col_bin}, this can be a simple numeric
range (e.g. \code{c(0, 100)}); \code{col_quantile} needs representative
numeric data; and \code{col_factor} needs categorical data.
If \code{NULL}, then whenever the resulting colour function is called, the
\code{x} value will represent the domain. This implies that if the function
is invoked multiple times, the encoding between values and colours may not
be consistent; if consistency is needed, you must provide a non-\code{NULL}
domain.}
\item{na.color}{The colour to return for \code{NA} values. Note that
\code{na.color = NA} is valid.}
\item{alpha}{Whether alpha channels should be respected or ignored. If \code{TRUE}
then colors without explicit alpha information will be treated as fully
opaque.}
\item{reverse}{Whether the colors (or color function) in \code{palette} should be
used in reverse order. For example, if the default order of a palette goes
from blue to green, then \code{reverse = TRUE} will result in the colors going
from green to blue.}
\item{bins}{Either a numeric vector of two or more unique cut points or a
single number (greater than or equal to 2) giving the number of intervals
into which the domain values are to be cut.}
\item{pretty}{Whether to use the function \code{\link[=pretty]{pretty()}} to generate
the bins when the argument \code{bins} is a single number. When
\code{pretty = TRUE}, the actual number of bins may not be the number of
bins you specified. When \code{pretty = FALSE}, \code{\link[=seq]{seq()}} is used
to generate the bins and the breaks may not be "pretty".}
\item{right}{parameter supplied to \code{\link[base:cut]{base::cut()}}. See Details}
\item{n}{Number of equal-size quantiles desired. For more precise control,
use the \code{probs} argument instead.}
\item{probs}{See \code{\link[stats:quantile]{stats::quantile()}}. If provided, the \code{n}
argument is ignored.}
\item{levels}{An alternate way of specifying levels; if specified, domain is
ignored}
\item{ordered}{If \code{TRUE} and \code{domain} needs to be coerced to a
factor, treat it as already in the correct order}
}
\value{
A function that takes a single parameter \code{x}; when called with a
vector of numbers (except for \code{col_factor}, which expects
factors/characters), #RRGGBB colour strings are returned (unless
\code{alpha = TRUE} in which case #RRGGBBAA may also be possible).
}
\description{
Conveniently maps data values (numeric or factor/character) to colours
according to a given palette, which can be provided in a variety of formats.
}
\details{
\code{col_numeric} is a simple linear mapping from continuous numeric data
to an interpolated palette.
\code{col_bin} also maps continuous numeric data, but performs
binning based on value (see the \code{\link[base:cut]{base::cut()}} function). \code{col_bin}
defaults for the \code{cut} function are \code{include.lowest = TRUE} and
\code{right = FALSE}.
\code{col_quantile} similarly bins numeric data, but via the
\code{\link[stats:quantile]{stats::quantile()}} function.
\code{col_factor} maps factors to colours. If the palette is
discrete and has a different number of colours than the number of factors,
interpolation is used.
The \code{palette} argument can be any of the following:
\enumerate{
\item{A character vector of RGB or named colours. Examples: \code{palette()}, \code{c("#000000", "#0000FF", "#FFFFFF")}, \code{topo.colors(10)}}
\item{The name of an RColorBrewer palette, e.g. \code{"BuPu"} or \code{"Greens"}.}
\item{The full name of a viridis palette: \code{"viridis"}, \code{"magma"}, \code{"inferno"}, or \code{"plasma"}.}
\item{A function that receives a single value between 0 and 1 and returns a colour. Examples: \code{colorRamp(c("#000000", "#FFFFFF"), interpolate="spline")}.}
}
}
\examples{
pal <- col_bin("Greens", domain = 0:100)
show_col(pal(sort(runif(10, 60, 100))))
# Exponential distribution, mapped continuously
show_col(col_numeric("Blues", domain = NULL)(sort(rexp(16))))
# Exponential distribution, mapped by interval
show_col(col_bin("Blues", domain = NULL, bins = 4)(sort(rexp(16))))
# Exponential distribution, mapped by quantile
show_col(col_quantile("Blues", domain = NULL)(sort(rexp(16))))
# Categorical data; by default, the values being coloured span the gamut...
show_col(col_factor("RdYlBu", domain = NULL)(LETTERS[1:5]))
# ...unless the data is a factor, without droplevels...
show_col(col_factor("RdYlBu", domain = NULL)(factor(LETTERS[1:5], levels = LETTERS)))
# ...or the domain is stated explicitly.
show_col(col_factor("RdYlBu", levels = LETTERS)(LETTERS[1:5]))
}
scales/man/rescale.Rd 0000644 0001762 0000144 00000003077 14522154141 014212 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bounds.R
\name{rescale}
\alias{rescale}
\alias{rescale.numeric}
\alias{rescale.dist}
\alias{rescale.logical}
\alias{rescale.POSIXt}
\alias{rescale.Date}
\alias{rescale.integer64}
\alias{rescale.difftime}
\alias{rescale.AsIs}
\title{Rescale continuous vector to have specified minimum and maximum}
\usage{
rescale(x, to, from, ...)
\method{rescale}{numeric}(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE), ...)
\method{rescale}{dist}(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE), ...)
\method{rescale}{logical}(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE), ...)
\method{rescale}{POSIXt}(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE), ...)
\method{rescale}{Date}(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE), ...)
\method{rescale}{integer64}(x, to = c(0, 1), from = range(x, na.rm = TRUE), ...)
\method{rescale}{difftime}(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE), ...)
\method{rescale}{AsIs}(x, to, from, ...)
}
\arguments{
\item{x}{continuous vector of values to manipulate.}
\item{to}{output range (numeric vector of length two)}
\item{from}{input range (vector of length two). If not given, is
calculated from the range of \code{x}}
\item{...}{other arguments passed on to methods}
}
\description{
Rescale continuous vector to have specified minimum and maximum
}
\details{
Objects of class \verb{} are returned unaltered.
}
\examples{
rescale(1:100)
rescale(runif(50))
rescale(1)
}
\keyword{manip}
scales/man/trim_to_domain.Rd 0000644 0001762 0000144 00000001030 14522421001 015553 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform.R
\name{trim_to_domain}
\alias{trim_to_domain}
\alias{trans_range}
\title{Compute range of transformed values}
\usage{
trim_to_domain(transform, x)
trans_range(transform, x)
}
\arguments{
\item{transform}{a transformation object, or the name of a transformation object
given as a string.}
\item{x}{a numeric vector to compute the range of}
}
\description{
Silently drops any ranges outside of the domain of \code{transform}.
}
\keyword{internal}
scales/man/label_number_auto.Rd 0000644 0001762 0000144 00000002637 14522154141 016254 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-number-auto.R
\name{label_number_auto}
\alias{label_number_auto}
\title{Label numbers, avoiding scientific notation where possible}
\usage{
label_number_auto()
}
\description{
Switches between \code{\link[=number_format]{number_format()}} and \code{\link[=scientific_format]{scientific_format()}} based on a set of
heuristics designed to automatically generate useful labels across a wide
range of inputs
}
\examples{
# Very small and very large numbers get scientific notation
demo_continuous(c(0, 1e-6), labels = label_number_auto())
demo_continuous(c(0, 1e9), labels = label_number_auto())
# Other ranges get the numbers printed in full
demo_continuous(c(0, 1e-3), labels = label_number_auto())
demo_continuous(c(0, 1), labels = label_number_auto())
demo_continuous(c(0, 1e3), labels = label_number_auto())
demo_continuous(c(0, 1e6), labels = label_number_auto())
# Transformation is applied individually so you get as little
# scientific notation as possible
demo_log10(c(1, 1e7), labels = label_number_auto())
}
\seealso{
Other labels for continuous scales:
\code{\link{label_bytes}()},
\code{\link{label_currency}()},
\code{\link{label_number_si}()},
\code{\link{label_ordinal}()},
\code{\link{label_parse}()},
\code{\link{label_percent}()},
\code{\link{label_pvalue}()},
\code{\link{label_scientific}()}
}
\concept{labels for continuous scales}
scales/man/new_transform.Rd 0000644 0001762 0000144 00000004533 14522421001 015446 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform.R
\name{new_transform}
\alias{new_transform}
\alias{trans}
\alias{trans_new}
\alias{is.transform}
\alias{is.trans}
\alias{as.transform}
\alias{as.trans}
\title{Create a new transformation object}
\usage{
new_transform(
name,
transform,
inverse,
d_transform = NULL,
d_inverse = NULL,
breaks = extended_breaks(),
minor_breaks = regular_minor_breaks(),
format = format_format(),
domain = c(-Inf, Inf)
)
trans_new(
name,
transform,
inverse,
d_transform = NULL,
d_inverse = NULL,
breaks = extended_breaks(),
minor_breaks = regular_minor_breaks(),
format = format_format(),
domain = c(-Inf, Inf)
)
is.transform(x)
is.trans(x)
as.transform(x, arg = deparse(substitute(x)))
as.trans(x, arg = deparse(substitute(x)))
}
\arguments{
\item{name}{transformation name}
\item{transform}{function, or name of function, that performs the
transformation}
\item{inverse}{function, or name of function, that performs the
inverse of the transformation}
\item{d_transform}{Optional function, or name of function, that gives the
derivative of the transformation. May be \code{NULL}.}
\item{d_inverse}{Optional function, or name of function, that gives the
derivative of the inverse of the transformation. May be \code{NULL}.}
\item{breaks}{default breaks function for this transformation. The breaks
function is applied to the un-transformed data.}
\item{minor_breaks}{default minor breaks function for this transformation.}
\item{format}{default format for this transformation. The format is applied
to breaks generated on the un-transformed data.}
\item{domain}{the allowed range of the data to be transformed. The function
in the \code{transform} argument is expected to be able to transform the \code{domain}
argument.}
}
\description{
A transformation encapsulates a transformation and its inverse, as well
as the information needed to create pleasing breaks and labels. The \code{breaks()}
function is applied on the un-transformed range of the data, and the
\code{format()} function takes the output of the \code{breaks()} function and returns
well-formatted labels. Transformations may also include the derivatives of the
transformation and its inverse, but are not required to.
}
\seealso{
\Sexpr[results=rd,stage=build]{scales:::seealso_transform()}
}
\keyword{internal}
scales/man/pal_grey.Rd 0000644 0001762 0000144 00000001062 14522421001 014356 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-grey.R
\name{pal_grey}
\alias{pal_grey}
\alias{grey_pal}
\title{Grey scale palette (discrete)}
\usage{
pal_grey(start = 0.2, end = 0.8)
grey_pal(start = 0.2, end = 0.8)
}
\arguments{
\item{start}{grey value at low end of palette}
\item{end}{grey value at high end of palette}
}
\description{
Grey scale palette (discrete)
}
\examples{
show_col(pal_grey()(25))
show_col(pal_grey(0, 1)(25))
}
\seealso{
\code{\link[=pal_seq_gradient]{pal_seq_gradient()}} for continuous version
}
scales/man/oob.Rd 0000644 0001762 0000144 00000007470 14520145514 013356 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bounds.R
\name{oob}
\alias{oob}
\alias{oob_censor}
\alias{oob_censor_any}
\alias{oob_discard}
\alias{oob_squish}
\alias{oob_squish_any}
\alias{oob_squish_infinite}
\alias{oob_keep}
\alias{censor}
\alias{discard}
\alias{squish}
\alias{squish_infinite}
\title{Out of bounds handling}
\usage{
oob_censor(x, range = c(0, 1), only.finite = TRUE)
oob_censor_any(x, range = c(0, 1))
oob_discard(x, range = c(0, 1))
oob_squish(x, range = c(0, 1), only.finite = TRUE)
oob_squish_any(x, range = c(0, 1))
oob_squish_infinite(x, range = c(0, 1))
oob_keep(x, range = c(0, 1))
censor(x, range = c(0, 1), only.finite = TRUE)
discard(x, range = c(0, 1))
squish(x, range = c(0, 1), only.finite = TRUE)
squish_infinite(x, range = c(0, 1))
}
\arguments{
\item{x}{A numeric vector of values to modify.}
\item{range}{A numeric vector of length two giving the minimum and maximum
limit of the desired output range respectively.}
\item{only.finite}{A logical of length one. When \code{TRUE}, only finite values
are altered. When \code{FALSE}, also infinite values are altered.}
}
\value{
Most \code{oob_()} functions return a vector of numerical values of the
same length as the \code{x} argument, wherein out of bounds values have been
modified. Only \code{oob_discard()} returns a vector of less than or of equal
length to the \code{x} argument.
}
\description{
This set of functions modify data values outside a given range.
The \verb{oob_*()} functions are designed to be passed as the \code{oob} argument of
ggplot2 continuous and binned scales, with \code{oob_discard} being an exception.
These functions affect out of bounds values in the following ways:
\itemize{
\item \code{oob_censor()} replaces out of bounds values with \code{NA}s. This is the
default \code{oob} argument for continuous scales.
\item \code{oob_censor_any()} acts like \code{oob_censor()}, but also replaces infinite
values with \code{NA}s.
\item \code{oob_squish()} replaces out of bounds values with the nearest limit. This
is the default \code{oob} argument for binned scales.
\item \code{oob_squish_any()} acts like \code{oob_squish()}, but also replaces infinite
values with the nearest limit.
\item \code{oob_squish_infinite()} only replaces infinite values by the nearest limit.
\item \code{oob_keep()} does not adjust out of bounds values. In position scales,
behaves as zooming limits without data removal.
\item \code{oob_discard()} removes out of bounds values from the input. Not suitable
for ggplot2 scales.
}
}
\details{
The \code{oob_censor_any()} and \code{oob_squish_any()} functions are the same
as \code{oob_censor()} and \code{oob_squish()} with the \code{only.finite} argument set to
\code{FALSE}.
Replacing position values with \code{NA}s, as \code{oob_censor()} does, will typically
lead to removal of those datapoints in ggplot.
Setting ggplot coordinate limits is equivalent to using \code{oob_keep()} in
position scales.
}
\section{Old interface}{
\code{censor()}, \code{squish()}, \code{squish_infinite()} and
\code{discard()} are no longer recommended; please use \code{oob_censor()},
\code{oob_squish()}, \code{oob_squish_infinite()} and \code{oob_discard()} instead.
}
\examples{
# Censoring replaces out of bounds values with NAs
oob_censor(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
oob_censor_any(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
# Squishing replaces out of bounds values with the nearest range limit
oob_squish(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
oob_squish_any(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
oob_squish_infinite(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
# Keeping does not alter values
oob_keep(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
# Discarding will remove out of bounds values
oob_discard(c(-Inf, -1, 0.5, 1, 2, NA, Inf))
}
\author{
\code{oob_squish()}: Homer Strong \href{mailto:homer.strong@gmail.com}{homer.strong@gmail.com}
}
scales/man/label_parse.Rd 0000644 0001762 0000144 00000003631 14522154141 015041 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-expression.R
\name{label_parse}
\alias{label_parse}
\alias{label_math}
\title{Label with mathematical annotations}
\usage{
label_parse()
label_math(expr = 10^.x, format = force)
}
\arguments{
\item{expr}{expression to use}
\item{format}{another format function to apply prior to mathematical
transformation - this makes it easier to use floating point numbers in
mathematical expressions.}
}
\value{
All \code{label_()} functions return a "labelling" function, i.e. a function that
takes a vector \code{x} and returns a character vector of \code{length(x)} giving a
label for each input value.
Labelling functions are designed to be used with the \code{labels} argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
}
\description{
\code{label_parse()} produces expression from strings by parsing them;
\code{label_math()} constructs expressions by replacing the pronoun \code{.x}
with each string.
}
\examples{
# Use label_parse() with discrete scales
greek <- c("alpha", "beta", "gamma")
demo_discrete(greek)
demo_discrete(greek, labels = label_parse())
# Use label_math() with continuous scales
demo_continuous(c(1, 5))
demo_continuous(c(1, 5), labels = label_math(alpha[.x]))
demo_continuous(c(1, 5), labels = label_math())
}
\seealso{
\link{plotmath} for the details of mathematical formatting in R.
Other labels for continuous scales:
\code{\link{label_bytes}()},
\code{\link{label_currency}()},
\code{\link{label_number_auto}()},
\code{\link{label_number_si}()},
\code{\link{label_ordinal}()},
\code{\link{label_percent}()},
\code{\link{label_pvalue}()},
\code{\link{label_scientific}()}
Other labels for discrete scales:
\code{\link{label_wrap}()}
}
\concept{labels for continuous scales}
\concept{labels for discrete scales}
scales/man/show_col.Rd 0000644 0001762 0000144 00000001525 14522421001 014375 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colour-manip.R
\name{show_col}
\alias{show_col}
\title{Show colours}
\usage{
show_col(colours, labels = TRUE, borders = NULL, cex_label = 1, ncol = NULL)
}
\arguments{
\item{colours}{A character vector of colours}
\item{labels}{Label each colour with its hex name?}
\item{borders}{Border colour for each tile. Default uses \code{par("fg")}.
Use \code{border = NA} to omit borders.}
\item{cex_label}{Size of printed labels, as multiplier of default size.}
\item{ncol}{Number of columns. If not supplied, tries to be as square as
possible.}
}
\description{
A quick and dirty way to show colours in a plot.
}
\examples{
show_col(pal_hue()(9))
show_col(pal_hue()(9), borders = NA)
show_col(pal_viridis()(16))
show_col(pal_viridis()(16), labels = FALSE)
}
\keyword{internal}
scales/man/rescale_mid.Rd 0000644 0001762 0000144 00000003040 14522154141 015031 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bounds.R
\name{rescale_mid}
\alias{rescale_mid}
\alias{rescale_mid.numeric}
\alias{rescale_mid.logical}
\alias{rescale_mid.dist}
\alias{rescale_mid.POSIXt}
\alias{rescale_mid.Date}
\alias{rescale_mid.integer64}
\alias{rescale_mid.AsIs}
\title{Rescale vector to have specified minimum, midpoint, and maximum}
\usage{
rescale_mid(x, to, from, mid, ...)
\method{rescale_mid}{numeric}(x, to = c(0, 1), from = range(x, na.rm = TRUE), mid = 0, ...)
\method{rescale_mid}{logical}(x, to = c(0, 1), from = range(x, na.rm = TRUE), mid = 0, ...)
\method{rescale_mid}{dist}(x, to = c(0, 1), from = range(x, na.rm = TRUE), mid = 0, ...)
\method{rescale_mid}{POSIXt}(x, to = c(0, 1), from = range(x, na.rm = TRUE), mid, ...)
\method{rescale_mid}{Date}(x, to = c(0, 1), from = range(x, na.rm = TRUE), mid, ...)
\method{rescale_mid}{integer64}(x, to = c(0, 1), from = range(x, na.rm = TRUE), mid = 0, ...)
\method{rescale_mid}{AsIs}(x, to, from, ...)
}
\arguments{
\item{x}{vector of values to manipulate.}
\item{to}{output range (numeric vector of length two)}
\item{from}{input range (vector of length two). If not given, is
calculated from the range of \code{x}}
\item{mid}{mid-point of input range}
\item{...}{other arguments passed on to methods}
}
\description{
Rescale vector to have specified minimum, midpoint, and maximum
}
\details{
Objects of class \verb{} are returned unaltered.
}
\examples{
rescale_mid(1:100, mid = 50.5)
rescale_mid(runif(50), mid = 0.5)
rescale_mid(1)
}
scales/man/transform_reverse.Rd 0000644 0001762 0000144 00000001042 14522421001 016320 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_reverse}
\alias{transform_reverse}
\alias{reverse_trans}
\title{Reverse transformation}
\usage{
transform_reverse()
reverse_trans()
}
\description{
reversing transformation works by multiplying the input with -1. This means
that reverse transformation cannot easily be composed with transformations
that require positive input unless the reversing is done as a final step.
}
\examples{
plot(transform_reverse(), xlim = c(-1, 1))
}
scales/man/label_currency.Rd 0000644 0001762 0000144 00000012010 14523373730 015560 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-currency.R
\name{label_currency}
\alias{label_currency}
\title{Label currencies ($100, €2.50, etc)}
\usage{
label_currency(
accuracy = NULL,
scale = 1,
prefix = "$",
suffix = "",
big.mark = ",",
decimal.mark = ".",
trim = TRUE,
largest_with_fractional = 1e+05,
...
)
}
\arguments{
\item{accuracy, largest_with_fractional}{Number to round
to. If \code{NULL}, the default, values will be rounded to the nearest integer,
unless any of the values has non-zero fractional component (e.g. cents) and
the largest value is less than \code{largest_with_fractional} which by default
is 100,000.}
\item{scale}{A scaling factor: \code{x} will be multiplied by \code{scale} before
formatting. This is useful if the underlying data is very small or very
large.}
\item{prefix, suffix}{Symbols to display before and after value.}
\item{big.mark}{Character used between every 3 digits to separate thousands.}
\item{decimal.mark}{The character to be used to indicate the numeric
decimal point.}
\item{trim}{Logical, if \code{FALSE}, values are right-justified to a common
width (see \code{\link[base:format]{base::format()}}).}
\item{...}{
Arguments passed on to \code{\link[=number]{number}}
\describe{
\item{\code{style_positive}}{A string that determines the style of positive numbers:
\itemize{
\item \code{"none"} (the default): no change, e.g. \code{1}.
\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}.
\item \code{"space"}: preceded by a Unicode "figure space", i.e., a space equally
as wide as a number or \code{+}. Compared to \code{"none"}, adding a figure space
can ensure numbers remain properly aligned when they are left- or
right-justified.
}}
\item{\code{style_negative}}{A string that determines the style of negative numbers:
\itemize{
\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}.
\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical
nicety that ensures \code{-} aligns with the horizontal bar of the
the horizontal bar of \code{+}.
\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}.
}}
\item{\code{scale_cut}}{Named numeric vector that allows you to rescale large
(or small) numbers and add a prefix. Built-in helpers include:
\itemize{
\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T.
\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T.
\item \code{cut_si(unit)}: uses standard SI units.
}
If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the
range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)}
will be divided by 100 and given the suffix "a", and absolute values in
the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".
If the division creates an irrational value (or one with many digits), the
cut value below will be tried to see if it improves the look of the final
label.}
}}
}
\value{
All \code{label_()} functions return a "labelling" function, i.e. a function that
takes a vector \code{x} and returns a character vector of \code{length(x)} giving a
label for each input value.
Labelling functions are designed to be used with the \code{labels} argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
}
\description{
Format numbers as currency, rounding values to monetary or fractional
monetary using unit a convenient heuristic.
}
\examples{
demo_continuous(c(0, 1), labels = label_currency())
demo_continuous(c(1, 100), labels = label_currency())
# Customise currency display with prefix and suffix
demo_continuous(c(1, 100), labels = label_currency(prefix = "USD "))
yen <- label_currency(
prefix = "ÂĄ",
suffix = "",
big.mark = ".",
decimal.mark = ","
)
demo_continuous(c(1000, 1100), labels = yen)
# Use style_negative = "parens" for finance style display
demo_continuous(c(-100, 100), labels = label_currency(style_negative = "parens"))
# Use scale_cut to use K/M/B where appropriate
demo_log10(c(1, 1e16),
breaks = log_breaks(7, 1e3),
labels = label_currency(scale_cut = cut_short_scale())
)
# cut_short_scale() uses B = one thousand million
# cut_long_scale() uses B = one million million
demo_log10(c(1, 1e16),
breaks = log_breaks(7, 1e3),
labels = label_currency(scale_cut = cut_long_scale())
)
# You can also define your own breaks
gbp <- label_currency(
prefix = "\u00a3",
scale_cut = c(0, k = 1e3, m = 1e6, bn = 1e9, tn = 1e12)
)
demo_log10(c(1, 1e12), breaks = log_breaks(5, 1e3), labels = gbp)
}
\seealso{
Other labels for continuous scales:
\code{\link{label_bytes}()},
\code{\link{label_number_auto}()},
\code{\link{label_number_si}()},
\code{\link{label_ordinal}()},
\code{\link{label_parse}()},
\code{\link{label_percent}()},
\code{\link{label_pvalue}()},
\code{\link{label_scientific}()}
}
\concept{labels for continuous scales}
scales/man/muted.Rd 0000644 0001762 0000144 00000000664 14520145514 013713 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colour-manip.R
\name{muted}
\alias{muted}
\title{Mute standard colour}
\usage{
muted(colour, l = 30, c = 70)
}
\arguments{
\item{colour}{character vector of colours to modify}
\item{l}{new luminance}
\item{c}{new chroma}
}
\description{
Mute standard colour
}
\examples{
muted("red")
muted("blue")
show_col(c("red", "blue", muted("red"), muted("blue")))
}
scales/man/format_format.Rd 0000644 0001762 0000144 00000001221 14520130030 015406 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/labels-retired.R
\name{format_format}
\alias{format_format}
\title{Label using \code{format()}}
\usage{
format_format(...)
}
\arguments{
\item{...}{Arguments passed on to \code{\link[=format]{format()}}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
This function is kept for backward compatiblity; you should either use
\code{\link[=label_number]{label_number()}} or \code{\link[=label_date]{label_date()}} instead.
}
\keyword{internal}
scales/man/transform_exp.Rd 0000644 0001762 0000144 00000001111 14522421001 015436 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_exp}
\alias{transform_exp}
\alias{exp_trans}
\title{Exponential transformation (inverse of log transformation)}
\usage{
transform_exp(base = exp(1))
exp_trans(base = exp(1))
}
\arguments{
\item{base}{Base of logarithm}
}
\description{
Exponential transformation (inverse of log transformation)
}
\examples{
plot(transform_exp(0.5), xlim = c(-2, 2))
plot(transform_exp(1), xlim = c(-2, 2))
plot(transform_exp(2), xlim = c(-2, 2))
plot(transform_exp(), xlim = c(-2, 2))
}
scales/man/transform_time.Rd 0000644 0001762 0000144 00000001250 14522421001 015604 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-date.R
\name{transform_time}
\alias{transform_time}
\alias{time_trans}
\title{Transformation for date-times (class POSIXt)}
\usage{
transform_time(tz = NULL)
time_trans(tz = NULL)
}
\arguments{
\item{tz}{Optionally supply the time zone. If \code{NULL}, the default,
the time zone will be extracted from first input with a non-null tz.}
}
\description{
Transformation for date-times (class POSIXt)
}
\examples{
hours <- seq(ISOdate(2000, 3, 20, tz = ""), by = "hour", length.out = 10)
t <- transform_time()
t$transform(hours)
t$inverse(t$transform(hours))
t$format(t$breaks(range(hours)))
}
scales/man/breaks_extended.Rd 0000644 0001762 0000144 00000001612 14520145514 015716 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/breaks.R
\name{breaks_extended}
\alias{breaks_extended}
\alias{extended_breaks}
\title{Automatic breaks for numeric axes}
\usage{
breaks_extended(n = 5, ...)
}
\arguments{
\item{n}{Desired number of breaks. You may get slightly more or fewer
breaks that requested.}
\item{...}{other arguments passed on to \code{\link[labeling:extended]{labeling::extended()}}}
}
\description{
Uses Wilkinson's extended breaks algorithm as implemented in the
\pkg{labeling} package.
}
\examples{
demo_continuous(c(0, 10))
demo_continuous(c(0, 10), breaks = breaks_extended(3))
demo_continuous(c(0, 10), breaks = breaks_extended(10))
}
\references{
Talbot, J., Lin, S., Hanrahan, P. (2010) An Extension of
Wilkinson's Algorithm for Positioning Tick Labels on Axes, InfoVis
2010 \url{http://vis.stanford.edu/files/2010-TickLabels-InfoVis.pdf}.
}
scales/man/wrap_format.Rd 0000644 0001762 0000144 00000001133 14520130030 015071 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/label-wrap.R
\name{wrap_format}
\alias{wrap_format}
\title{Superseded interface to \code{label_wrap()}}
\usage{
wrap_format(width)
}
\arguments{
\item{width}{Number of characters per line.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
These functions are kept for backward compatibility; you should switch
to \code{\link[=label_wrap]{label_wrap()}} for new code.
}
\keyword{internal}
scales/man/col2hcl.Rd 0000644 0001762 0000144 00000001450 14520145514 014115 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colour-manip.R
\name{col2hcl}
\alias{col2hcl}
\title{Modify standard R colour in hcl colour space.}
\usage{
col2hcl(colour, h = NULL, c = NULL, l = NULL, alpha = NULL)
}
\arguments{
\item{colour}{character vector of colours to be modified}
\item{h}{Hue, \verb{[0, 360]}}
\item{c}{Chroma, \verb{[0, 100]}}
\item{l}{Luminance, \verb{[0, 100]}}
\item{alpha}{Alpha, \verb{[0, 1]}.}
}
\description{
Transforms rgb to hcl, sets non-missing arguments and then backtransforms
to rgb.
}
\examples{
reds <- rep("red", 6)
show_col(col2hcl(reds, h = seq(0, 180, length = 6)))
show_col(col2hcl(reds, c = seq(0, 80, length = 6)))
show_col(col2hcl(reds, l = seq(0, 100, length = 6)))
show_col(col2hcl(reds, alpha = seq(0, 1, length = 6)))
}
scales/man/pal_dichromat.Rd 0000644 0001762 0000144 00000001411 14522421001 015360 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal-dichromat.R
\name{pal_dichromat}
\alias{pal_dichromat}
\alias{dichromat_pal}
\title{Dichromat (colour-blind) palette (discrete)}
\usage{
pal_dichromat(name)
dichromat_pal(name)
}
\arguments{
\item{name}{Name of colour palette. One of:
\Sexpr[results=rd,stage=build]{scales:::dichromat_schemes()}}
}
\description{
Dichromat (colour-blind) palette (discrete)
}
\examples{
if (requireNamespace("dichromat", quietly = TRUE)) {
show_col(pal_dichromat("BluetoOrange.10")(10))
show_col(pal_dichromat("BluetoOrange.10")(5))
# Can use with gradient_n to create a continous gradient
cols <- pal_dichromat("DarkRedtoBlue.12")(12)
show_col(pal_gradient_n(cols)(seq(0, 1, length.out = 30)))
}
}
scales/man/train_continuous.Rd 0000644 0001762 0000144 00000000632 14520145515 016174 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scale-continuous.R
\name{train_continuous}
\alias{train_continuous}
\title{Train (update) a continuous scale}
\usage{
train_continuous(new, existing = NULL)
}
\arguments{
\item{new}{New data to add to scale}
\item{existing}{Optional existing scale to update}
}
\description{
Strips attributes and always returns a numeric vector
}
scales/man/transform_asinh.Rd 0000644 0001762 0000144 00000000560 14522421001 015753 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform-numeric.R
\name{transform_asinh}
\alias{transform_asinh}
\alias{asinh_trans}
\title{Inverse Hyperbolic Sine transformation}
\usage{
transform_asinh()
asinh_trans()
}
\description{
Inverse Hyperbolic Sine transformation
}
\examples{
plot(transform_asinh(), xlim = c(-1e2, 1e2))
}
scales/man/expand_range.Rd 0000644 0001762 0000144 00000001022 14520145514 015215 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bounds.R
\name{expand_range}
\alias{expand_range}
\title{Expand a range with a multiplicative or additive constant}
\usage{
expand_range(range, mul = 0, add = 0, zero_width = 1)
}
\arguments{
\item{range}{range of data, numeric vector of length 2}
\item{mul}{multiplicative constant}
\item{add}{additive constant}
\item{zero_width}{distance to use if range has zero width}
}
\description{
Expand a range with a multiplicative or additive constant
}
scales/man/figures/ 0000755 0001762 0000144 00000000000 14531055367 013754 5 ustar ligges users scales/man/figures/README-labels-1.png 0000644 0001762 0000144 00000156156 14531055367 017033 0 ustar ligges users ‰PNG
IHDR ŕ l< ! iCCPkCGColorSpaceGenericRGB 8ŤŤU]hU>›ął+$ÎÔ¦¦’ţ5”´lRŃ„ÚčţełmÜ,“l´AÉěÝťi&3ăü¤i)>AÁ¨ŕ“ŕ˙[Á'!j«í‹-˘´P˘(řĐúGˇŇ ëą3ł»“¸k˝ËÜůćśď~çŢsî޸,[–Ţ%,®-ĺÓâłÇćÄÄ:tÁ}Đ
}Đ-+Ž•*•&ăÂżÚíď ĆŢ×ö·÷˙gë®PG݅ج8Ę"âe ţŲ]€AűČ ×bř Ä;lś âõ Wžđ˛Ď™‘2_E,(ŞŚţÄŰç#öZsđŰŽ<5¨)"ËEÉ6«šN#Ó˝ű¶EÝkÄŰOŹł0}߸ö—*r–ᇟUäÜtŻ.iłĹ˙eąi ń# ]»Ľ…r
ń>ÄcU{Ľčt©Ş7ŃŔ+§Ô™gßxuÁ<ĘĆîDüµ1_ś
u~Rść ŕâ*-°z÷#°Mi*ËŤWh6Çňř¸ćf}î-gi:×Đ9ĄfŠA,î‹ăňV§>ÄW©ž—Bý_-·Ć%=†^śtČ0uüőúvWť™â’9Ś%/VµńBČWµ'¤_¶tŹâÜČMۓʟżźĺP““í\>ÄŤÉ@Á„yě0`D i|[`٧
čhˇčĄhˇřŐŕěßÂ)ůţ ·TjţČëčŃ0B¦˙#đĐŞÂďhU#Ľ~yh«uĐ fp#Ô1I/I’ř"“ä0!Ł ’'ÉSdŚdŃ:J5Ç–"sdóąŃÔy#Rź7‹Ľ‹čwAĆţgdŕ´ĎĹJź7ŘĎŘĎkĘ•×n^:}nW‹»FVź»Ösét$gj-tČÚÔťrĎ˙Â_ç×°_ç7Zţ~ëŰV·5ë4ĚV
}şo[ÄGó=Nd>Ą-UlałŁ˘Y5VúË }ąx»g[üä÷É?’kÉ÷’&ăŢä>áÎsźrźq߀Č]ŕ.r_r_qsźGjÔyď4k±
ći—QÜźBZŘ-<(d…=ÂĂÂdKO膄 a/zv7«Ť]»Ç°od«}¬€©sěn¬łÖá?TF–'|¦ăď3Nnă„#I?"…m»z„íő¦v~K=ÚŻĆsńl<b|_|4>?Âpß‹ľQěńÔré˛ËâŚiť´µšęŠĂÉäăb
Ż2*ĺŔ (ëşč»Ń¦µ—hĺ °{28ÂoIţýŰyĄesź8ü';÷Z¶9ŕ¬ĐűhË6€gă˝ď ¬>¦xöRx'Äbß8ŐĂÁWOĎ«ëő[xn%Ţ Ř|˝^˙űýz}óÔß ¸ ˙˙%xĹcÖË 8eXIfMM * ‡i ŕ LŠ‹‘ @ IDATxěÝŘ5WU>üR˙DbDPšŠB^DD!ˇ—$˝Jé!ˇ&@B
!4Ch!@ÁĐ‚vQŔD:¨ ŕ÷˝żIîÇýîĚĚ™9gÎóg]×óĚś)»¬˝öş×Z»Ěţżť´ićŔĚ™3fĚŘV\p[s›3›90s`ćŔĚ™3Ě <ÂĚ™3fĚŘ
x70}ÎrćŔĚ™3fl+ ë[ßZ|čC:×?ő©O-Î<óĚĹ—ľôĄ{ď{ßű_ř¶~;ůđ‡?ĽřŔ>°ËµůÇĚ™3fĚŘ9°m üío{qÄG,N;í´]řtĚ1Ç,žő¬g->ń‰O,îuŻ{->÷ąĎ5÷_ůĘW.>ó™Ďl=űĆ7ľqńĚg>sqµ«]mëÚ|2s`ćŔĚ™3öVl öłź]vŘa‹o~ó›»đéśsÎi<Ú—ľôĄ‹G?úŃ‹>xńÚ׾v—gü ľŻ{ÝëÇwÜâŞW˝ęůîĎfĚ90s`ćŔŢĆŘŽ˙çţçâńŹüâË_ţňâďxÇV–€ůZ׺Öâ‚<׸Îu®ł8ýôÓ·î;yĂްxӛ޴8ţřăWĽâwąçÇÉ'źĽřä'?ąuýđĂß:_çä¸@S®ď˙űë$ÓűîüŔ,ţçţ§ůë}pŤ›ňřŢ÷ľ·F
ýŻj;›ĚăBşPĂŁM®»đ…/ÜÔa“y¨Ç¦ĺIů7ťÇ&Űš,áÓwżűÝ~Á[ă®<đi“m˝/Č“v@›”§M÷ zśÜ¤<ÉĂ]^“ëżřĹëË[ż·€ŻyÍk6žuÖY[;ůüç?ż¸ôĄ/˝uí˙ýż˙×€t.Ľĺ-oYüůź˙ůâ*WąĘâr—»\.ďr4NüéOzëÁź‚0.ŕ2Ezmi(«Fۤ€>uŮé@ř´é<đi“
ó"ąHS‡Mĺ±ň¤•_{lŠ6-OĘ.ŹMRřÓ¦0§ĘwÓň¤śř´Ic(í°é<6™ţî–§˙ţď˙î©ÍJzoÖ‹ĆŇ-ÁGC\ěbŰzë‹_üb’ć=żčE/Z<ä!Ůş—“‡?üá! >>e©ĂćS¤ť4.ůË/ľóťď,ľńŤoäŇäÇË^ö˛‹Ż~ő«“§›/u©K5|ÝŘ]ň’—lř´)+–q…+\ˇikí± ˘Ôc“mýĂ?üĂŤĄ˙őŻ}UhŇÜ´<ńĺ›”'yĐ;›lkŃ:“NÍ}Ů]ć2—Y|ík_ŰTňmÍpüĘWľ˛±<6]:\ę°)ăú˘˝hç˙úŻ˙:ź~đđ|×Ę›3•Ë\:ÎPٸίtĄ+m=}źűÜgA©+żýíooťA˝őđ|2s`ćŔĚ™3ö"ěV ľţőŻżřËżüËĹ?ýÓ?5ˇ”·˝ím‹Üŕ[ěKXóĘWľňâˇ}čâiO{Úâß˙ýß·îĎ'3fĚ90s`oĺŔn`cľ÷˝ď}÷ľ÷˝w˝ë]›ŕ!‡ŇĘË[Ţň–‹k_űÚ‹#Ź