-
Notifications
You must be signed in to change notification settings - Fork 25
/
subscale_thickness.Rd
executable file
·83 lines (74 loc) · 3.04 KB
/
subscale_thickness.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/subscale.R
\name{subscale_thickness}
\alias{subscale_thickness}
\title{Sub-scale for thickness aesthetic}
\usage{
subscale_thickness(
x,
limits = function(l) c(min(0, l[1]), l[2]),
expand = c(0, 0)
)
}
\arguments{
\item{x}{a \link{numeric} vector to be rescaled.
Typically provided automatically by \code{\link[=geom_slabinterval]{geom_slabinterval()}}.}
\item{limits}{One of:
\itemize{
\item \code{NULL} to use the range of the data
\item A \link{numeric} vector of length two providing the limits of the scale. Use
\code{NA} to use the default minimum or maximum.
\item A function that accepts a length-2 \link{numeric} vector of the automatic
limits and returns new limits. Unlike positional scales. Unlike
positional scales, these limits will not remove data.
}}
\item{expand}{A numeric vector of limit expansion constants of length
2 or 4, following the same format used by the \code{expand} argument of
\code{\link[=continuous_scale]{continuous_scale()}}. The default is not to expand the limits.
You can use the convenience function \code{\link[=expansion]{expansion()}} to generate the
expansion values; expanding the lower limit is usually not recommended
(because with most \code{thickness} scales the lower limit is the baseline
and represents \code{0}), so a typical usage might be something like
\code{expand = expansion(c(0, 0.05))} to expand the top end of the scale
by 5\%.}
}
\value{
A \link{thickness} vector of the same length as \code{x} scaled to be between
\code{0} and \code{1}.
}
\description{
This is a sub-scale intended for adjusting the scaling of the \code{thickness}
aesthetic at a geometry (or sub-geometry) level in \pkg{ggdist}. It can be
used with the \code{subscale} parameter of \code{\link[=geom_slabinterval]{geom_slabinterval()}}.
Supports \link[=auto_partial]{automatic partial function application} with
\link[=waiver]{waived arguments}.
}
\examples{
library(ggplot2)
library(distributional)
df = data.frame(d = dist_normal(2:3, 1), g = c("a", "b"))
# breaks on thickness subguides are always limited to the bounds of the
# subscale, which may leave labels off near the edge of the subscale
# (e.g. here `0.4` is omitted because the max value is approx `0.39`)
ggplot(df, aes(xdist = d, y = g)) +
stat_slabinterval(
subguide = "inside"
)
# We can use the subscale to expand the upper limit of the thickness scale
# by 5\% (similar to the default for positional scales), allowing bounds near
# (but just less than) the limit, like `0.4`, to be shown.
ggplot(df, aes(xdist = d, y = g)) +
stat_slabinterval(
subguide = "inside",
subscale = subscale_thickness(expand = expansion(c(0, 0.5)))
)
}
\seealso{
The \link{thickness} datatype.
The \code{thickness} aesthetic of \code{\link[=geom_slabinterval]{geom_slabinterval()}}.
\code{\link[=scale_thickness_shared]{scale_thickness_shared()}}, for setting a \code{thickness} scale across
all geometries using the \code{thickness} aesthetic.
Other sub-scales:
\code{\link{subscale_identity}()}
}
\concept{sub-scales}