View source: R/guide-axis-base.R
guide_axis_base | R Documentation |
This axis guide is a visual representation of position scales and can
represent the x
, y
, theta
and r
aesthetics. It differs from
guide_axis()
in that it can accept custom keys
and is can act as an axis for coord_radial()
like
guide_axis_theta()
.
guide_axis_base(
key = NULL,
title = waiver(),
theme = NULL,
n.dodge = 1,
check.overlap = FALSE,
angle = waiver(),
cap = "none",
bidi = FALSE,
order = 0,
position = waiver()
)
key |
A standard key specification. Defaults to
|
title |
A |
theme |
A |
n.dodge |
An positive |
check.overlap |
A |
angle |
A specification for the text angle. Compared to setting the
|
cap |
A method to cap the axes. One of the following:
|
bidi |
A |
order |
A positive |
position |
A |
Under the hood, this guide is a stack composition of a line, ticks and labels primitives.
To set minor ticks, use key = "minor"
, or use the type
argument in
key_manual()
or key_map()
.
To use this as a logarithmic axis, set key = "log"
.
A <Guide>
object.
Other standalone guides:
guide_axis_dendro()
,
guide_axis_nested()
,
guide_circles()
,
guide_colbar()
,
guide_colring()
,
guide_colsteps()
,
guide_legend_base()
,
guide_legend_cross()
,
guide_legend_group()
# A standard plot with custom keys
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(
guide = guide_axis_base(key = key_minor())
) +
scale_y_continuous(
guide = guide_axis_base(key = key_manual(c(20, 25, 30, 40)))
)
p
# Is translated to theta axis without fuss
p + coord_radial()
# To use as logarithmic axis:
ggplot(msleep, aes(bodywt, brainwt)) +
geom_point(na.rm = TRUE) +
scale_x_continuous(
transform = "log10",
guide = guide_axis_base("log")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.