Controls the axis title, limits, tick positions, tick labels, the padding around the data, and the axis transform.

scale_x_continuous(
  name = NULL,
  limits = NULL,
  breaks = NULL,
  labels = NULL,
  expand = 0.05,
  trans = "identity"
)

scale_y_continuous(
  name = NULL,
  limits = NULL,
  breaks = NULL,
  labels = NULL,
  expand = 0.05,
  trans = "identity"
)

Arguments

name

Axis title (defaults to the mapped expression).

limits

Optional numeric length-2 domain; NULL trains from data.

breaks

Explicit tick positions in data units, or NULL for automatic "nice number" breaks.

labels

Tick labels: a character vector the same length as breaks, a function applied to the break values (e.g. function(x) paste0("$", x)), or NULL for automatic formatting.

expand

Fraction of the data span to pad onto each end of the axis (default 5%). Use 0 for a tight axis.

trans

Axis transform: "identity", "log10", "sqrt", or "reverse".

Value

A ScaleContinuous object to add with +.

Examples

ggnext(cars, aes(speed, dist)) +
  geom_point() +
  scale_x_continuous(
    name = "Speed (mph)",
    breaks = c(5, 10, 15, 20, 25),
    expand = 0
  ) +
  scale_y_continuous(labels = function(v) paste0(v, " ft"))
#> <ggnext plot>
#>   data:  50 x 2
#>   aes:   x = speed, y = dist
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static