scale_multi {loon.ggplot} | R Documentation |
Position scales for continuous data (x, y & z)
Description
Scaling the coordinates for 3D visualization
Usage
scale_multi(trans = scaleBox(center = TRUE), ...)
Arguments
trans |
For continuous scales, the name of a transformation object or the object itself.
Built-in transformations include "asn", "atanh", "boxcox", "date", "exp", "hms", "identity", "log", "log10", "log1p",
"log2", "logit", "modulus", "probability", "probit", "pseudo_log", "reciprocal", "reverse", "sqrt" and "time".
A transformation object bundles together a transform, its inverse, and methods for generating breaks and labels.
Transformation objects are defined in the scales package, and are called <name>_trans (e.g., |
... |
Other arguments passed on to |
Details
In 3D rotation, different scales of variables x, y and z may cause an issue that the points appear to be
off the window even with a minor tweak. Additionally, if one variable is in a large scale,
the shape of the 3D plot may be dominated. Setting scale_multi
can ensure the scales in the same measurement, as
we rotate the plot, most points will stay inside the current view.
Value
a list of the ggproto
objects
Examples
if(interactive()) {
dsamp <- dplyr::sample_n(diamonds, 100)
## Not run:
# press `R`, then rotate with a minor tweak,
# Issues:
# 1: Points are displayed outside the window
# 2: Always in a line shape
l_ggplot(dsamp, aes(x = carat, y = price,
z = depth, colour = color)) +
geom_point()
## End(Not run)
# set scales
l_ggplot(dsamp, aes(x = carat, y =price,
z = depth, colour = color)) +
geom_point() +
scale_multi()
# customized `trans`
logp1_base10_trans <- scales::trans_new(
name = "logp",
trans = function(x) log(x + 1, base = 10),
inverse = function(x) 10**x - 1,
breaks = scales::log_breaks())
l_ggplot(dsamp, aes(x = carat, y = price,
z = depth, colour = color)) +
geom_point() +
scale_multi(trans = logp1_base10_trans)
}