annotation_compass: Adding Text to a ggplot2 Object

View source: R/graphic_functions.R

annotation_compassR Documentation

Adding Text to a ggplot2 Object

Description

This function adds text to the specified places (using compass style) of a ggplot2 object.

Usage

annotation_compass(
  label,
  position = c("N", "NE", "E", "SE", "S", "SW", "W", "NW"),
  padding = grid::unit(c(0.5, 0.5), "line"),
  ...
)

Arguments

label

character. Label of the legend

position

Position of the legend. Options are "N", "NE", "E", "SE", "S", "SW", "W", "NW".

padding

A numeric vector or unit object specifying x-values and y-values. Default is grid::unit(c(0.5, 0.5), "line")

...

Other arguments

Value

A ggplot2 object with legend.

Author(s)

Omer Kara

References

For more information see here.

Examples

## Not run: 
g + annotation_compass(label = "sometext", position = "NE") ## Do not run.

## To do the same, you can always use:
g + geom_text(data = data.frame(), aes(label = "sometext",
              x = -Inf, y = Inf), hjust = 0, vjust = 1) ## Do not run.
g + ggplot2::annotate(geom = "text", label = "sometext",
                      x = Inf, y = Inf, hjust = 1,
                      vjust = 1, size = 24) ## Do not run.

## End(Not run)


omerkara/okara documentation built on Nov. 21, 2023, 7:56 p.m.