View source: R/guide-axis-logticks.R
guide_axis_logticks | R Documentation |
This axis guide replaces the placement of ticks marks at intervals in log10 space.
guide_axis_logticks(
long = 2.25,
mid = 1.5,
short = 0.75,
prescale.base = NULL,
negative.small = 0.1,
short.theme = element_line(),
expanded = TRUE,
cap = "none",
theme = NULL,
prescale_base = deprecated(),
negative_small = deprecated(),
short_theme = deprecated(),
...
)
long , mid , short |
A |
prescale.base |
Base of logarithm used to transform data manually. The
default, |
negative.small |
When the scale limits include 0 or negative numbers, what should be the smallest absolute value that is marked with a tick? |
short.theme |
A theme element for customising the
display of the shortest ticks. Must be a line or blank element, and
it inherits from the |
expanded |
Whether the ticks should cover the range after scale
expansion ( |
cap |
A |
theme |
A |
prescale_base , negative_small , short_theme |
|
... |
Arguments passed on to
|
# A standard plot
p <- ggplot(msleep, aes(bodywt, brainwt)) +
geom_point(na.rm = TRUE)
# The logticks axis works well with log scales
p + scale_x_log10(guide = "axis_logticks") +
scale_y_log10(guide = "axis_logticks")
# Or with log-transformed coordinates
p + coord_trans(x = "log10", y = "log10") +
guides(x = "axis_logticks", y = "axis_logticks")
# When data is transformed manually, one should provide `prescale.base`
# Keep in mind that this axis uses log10 space for placement, not log2
p + aes(x = log2(bodywt), y = log10(brainwt)) +
guides(
x = guide_axis_logticks(prescale.base = 2),
y = guide_axis_logticks(prescale.base = 10)
)
# A plot with both positive and negative extremes, pseudo-log transformed
set.seed(42)
p2 <- ggplot(data.frame(x = rcauchy(1000)), aes(x = x)) +
geom_density() +
scale_x_continuous(
breaks = c(-10^(4:0), 0, 10^(0:4)),
transform = "pseudo_log"
)
# The log ticks are mirrored when 0 is included
p2 + guides(x = "axis_logticks")
# To control the tick density around 0, one can set `negative.small`
p2 + guides(x = guide_axis_logticks(negative.small = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.