Skip to contents

This is very similar to a regular axis guide, with the addition that it also places tick marks at minor break locations. The minor_breaks argument to scale_{x/y}_continuous() controls where the breaks are placed.

Usage

guide_axis_minor(minor_size = 0.75, major_size = 1, ...)

Arguments

minor_size

A numeric(1) giving the relative size of minor axis ticks relative to major axis ticks, as defined by the axis.ticks.length.{x/y}.{position} theme element. If NULL (default), minor axis ticks are not shown.

major_size

A numeric(1) giving the relative size of major ticks relative to the axis.ticks.length.{x/y}.{position} theme element. If NULL (default), major ticks are drawn to the theme's length.

...

Arguments passed on to guide_axis_extend

subtitle

A character() or expression() giving a subtitle for the guide. If NULL (default), no subtitle will be shown. If length(subtitle) > 1, text will be distributed over axis and hjust setting will be ignored.

subtitle.theme

An <element_text> object or <element_blank> object controlling the appearance of the subtitle argument. By default, it inherits from the relevant axis.text.{x/y}.{position} theme setting.

cap_lower,cap_upper

A way to set the lower and upper ranges for axis capping Can be one of the following:

  • NULL to not perform any axis capping.

  • A function that takes the break positions as input and returns the lower or upper boundary. Note that also for discrete scales, the inputs are the mapped breaks, which are numeric. A function input can also be given as lambda syntax.

  • A numeric value, in data units, for the lower and upper boundaries.

  • A <unit> object to set the boundaries independent of any data.

colour,color

A character(1) with a valid colour for simultaneously changing the colour or the axis text, axis ticks and axis line. If NULL (default), inherit colours directly from the theme. Otherwise, theme settings are overruled.

title

A character string or expression indicating a title of guide. If NULL, the title is not shown. By default (waiver()), the name of the scale object or the name specified in labs() is used for the title.

check.overlap

silently remove overlapping labels, (recursively) prioritizing the first, last, and middle labels.

angle

Compared to setting the angle in theme() / element_text(), this also uses some heuristics to automatically pick the hjust and vjust that you probably want.

n.dodge

The number of rows (for vertical axes) or columns (for horizontal axes) that should be used to render the labels. This is useful for displaying labels that would otherwise overlap.

order

A positive integer of length 1 that specifies the order of this guide among multiple guides. This controls in which order guides are merged if there are multiple guides for the same position. If 0 (default), the order is determined by a secret algorithm.

position

Where this guide should be drawn: one of top, bottom, left, or right.

Value

A <Guide> ggproto object that can be given to the guides() function, or set as the guide argument in a position scale.

See also

Examples

# A basic plot
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point()

# Show minor ticks
p + guides(x = "axis_minor")


# Controlling tick size relative to normal ticks
p + guides(x = guide_axis_minor(minor_size = 2))


# Only show minor ticks
p + guides(x = guide_axis_minor(minor_size = 1, major_size = 0))