adjust_x_axis | R Documentation |
Adjust axes
adjust_x_axis(
plot,
title = ggplot2::waiver(),
breaks = ggplot2::waiver(),
labels = ggplot2::waiver(),
limits = NULL,
padding = c(NA, NA),
rotate_labels = FALSE,
transform = "identity",
cut_short_scale = FALSE,
force_continuous = FALSE,
...
)
adjust_y_axis(
plot,
title = ggplot2::waiver(),
breaks = ggplot2::waiver(),
labels = ggplot2::waiver(),
limits = NULL,
padding = c(NA, NA),
rotate_labels = FALSE,
transform = "identity",
cut_short_scale = FALSE,
force_continuous = FALSE,
...
)
plot |
A |
title |
Axis title. |
breaks |
One of:
|
labels |
One of the options below. Please note that when
|
limits |
Axis limits. For example, with |
padding |
Extra space between the data points and the axes. Defaults to |
rotate_labels |
Whether to rotate axis labels. If |
transform |
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 |
cut_short_scale |
Whether to shorten axis labels using |
force_continuous |
Whether to force the axis to be continuous. Defaults to |
... |
Arguments passed on to ggplot2 |
The title
argument of adjust_x_axis()
and adjust_y_axis()
supports plotmath expressions to include special characters.
See examples and Advanced plotting.
A tidyplot
object.
# Plot without adjustments
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points()
# New titles
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points() |>
adjust_x_axis(title = "My new x-axis title") |>
adjust_y_axis(title = "My new y-axis title")
# New titles with plotmath expressions
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points() |>
adjust_x_axis(title = "$H[2]*O$") |>
adjust_y_axis(title = "$E==m*c^{2}$")
# Axes limits
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points() |>
adjust_x_axis(limits = c(-1000, 4000)) |>
adjust_y_axis(limits = c(-200, 600))
# Rotate labels
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points() |>
adjust_x_axis(rotate_labels = 90) |>
adjust_y_axis(rotate_labels = 90)
# Increase plot area padding
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points() |>
adjust_x_axis(padding = c(0.2, 0.2)) |>
adjust_y_axis(padding = c(0.2, 0.2))
# Scale transformation
animals |>
tidyplot(x = weight, y = size, color = family) |>
add_data_points() |>
adjust_x_axis(transform = "log10") |>
adjust_y_axis(transform = "log2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.