Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

insert_xaxis_grob

Insert an axis-like grob on either side of a plot panel in a ggplot2 plot.


Description

The function insert_xaxis_grob() inserts a grob at the top or bottom of the plot panel in a ggplot2 plot.

Usage

insert_xaxis_grob(
  plot,
  grob,
  height = grid::unit(0.2, "null"),
  position = c("top", "bottom"),
  clip = "on"
)

insert_yaxis_grob(
  plot,
  grob,
  width = grid::unit(0.2, "null"),
  position = c("right", "left"),
  clip = "on"
)

Arguments

plot

The plot into which the grob will be inserted.

grob

The grob to insert. This will generally have been obtained via get_panel() from a ggplot2 object, in particular one generated with axis_canvas(). If a ggplot2 plot is provided instead of a grob, then get_panel() is called to extract the panel grob.

height

The height of the grob, in grid units. Used by insert_xaxis_grob().

position

The position of the grob. Can be "right" or "left" for insert_yaxis_grob() and "top" or "botton" for insert_xaxis_grob().

clip

Set to "off" to turn off clipping of the inserted grob.

width

The width of the grob, in grid units. Used by insert_yaxis_grob().

Details

For usage examples, see axis_canvas().


cowplot

Streamlined Plot Theme and Plot Annotations for 'ggplot2'

v1.1.1
GPL-2
Authors
Claus O. Wilke [aut, cre] (<https://orcid.org/0000-0002-7470-9261>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.