subscale_thickness | R Documentation |
This is a sub-scale intended for adjusting the scaling of the thickness
aesthetic at a geometry (or sub-geometry) level in ggdist. It can be
used with the subscale
parameter of geom_slabinterval()
.
Supports automatic partial function application with waived arguments.
subscale_thickness(
x,
limits = function(l) c(min(0, l[1]), l[2]),
expand = c(0, 0)
)
x |
<numeric> Vector to be rescaled.
Typically provided automatically by |
limits |
<length-2 numeric | function | NULL> One of:
|
expand |
<numeric> Vector of limit expansion constants of length
2 or 4, following the same format used by the |
You can overwrite subscale_thickness
in the global environment to set
the default properties of the thickness subscale. For example:
subscale_thickness = ggdist::subscale_thickness(expand = expansion(c(0, 0.05)))
This will cause geom_slabinterval()
s to default to a thickness subscale
that expands by 5% at the top of the scale. Always prefix such a
definition with ggdist::
to avoid infinite loops caused by recursion.
A thickness vector of the same length as x
scaled to be between
0
and 1
.
The thickness datatype.
The thickness
aesthetic of geom_slabinterval()
.
scale_thickness_shared()
, for setting a thickness
scale across
all geometries using the thickness
aesthetic.
Other sub-scales:
subscale_identity()
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)))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.