Skip to contents

Draws axis ticks at specified break positions along a floating axis line. Requires coord_cartesian(clip = "off").

Usage

axis_ticks(
  xintercept = NULL,
  yintercept = NULL,
  breaks,
  length = ggplot2::rel(1),
  colour = NULL,
  linewidth = NULL,
  linetype = NULL,
  arrow = NULL,
  layout = NULL
)

Arguments

xintercept

One or more x positions for vertical axis lines, in data coordinates or wrapped in I() for normalised panel coordinates (npc). May be a vector; each value produces a separate axis.

yintercept

One or more y positions for horizontal axis lines, in data coordinates or wrapped in I() for normalised panel coordinates (npc). May be a vector; each value produces a separate axis.

breaks

A numeric vector of break positions in data coordinates, or wrapped in I() for npc. Pass a list the same length as the total number of axes (xintercept + yintercept combined) to use different breaks per axis.

length

Total tick length. Supports rel(). Negative values flip the tick direction. Defaults to rel(1) (theme tick length). May be a vector the same length as the number of axes.

colour

Inherits from axis.ticks in the set theme. May be a vector the same length as the number of axes — one style per axis, applied to all breaks on that axis.

linewidth

Inherits from axis.ticks in the set theme. Supports rel(). May be a vector the same length as the number of axes.

linetype

Inherits from axis.ticks in the set theme. May be a vector the same length as the number of axes.

arrow

A grid::arrow() specification, or a list the same length as the number of axes. The arrowhead points toward the axis line. Must use list() not c() when supplying multiple values. E.g. grid::arrow(angle = 15, length = unit(1.5, "mm"), type = "closed").

layout

Controls which panels the annotation appears in. NULL (default) repeats in all panels. An integer targets a specific panel. "fixed" repeats in all panels ignoring faceting variables. See ggplot2::layer() for full details.

Value

A list of ggplot2 annotation layers.

Details

Ticks always point in the positive direction by default (right for xintercept, up for yintercept). Use a negative length (e.g. length = -rel(1)) to flip them left or down.