grattan_arrow: Create arrows in the Grattan style

View source: R/grattan_arrow.R

grattan_arrowR Documentation

Create arrows in the Grattan style

Description

'grattan_arrow()' adds arrows to lines using 'grid::arrow()'. The arrows will have a closed arrow head, in keeping with Grattan Institute's visual style.

Usage

grattan_arrow(..., type = "closed", angle = 20, length = unit(0.5, "lines"))

Arguments

...

Arguments passed on to either 'grid::arrow()'. See ?arrow.

type

Arrow head type. Default is "closed".

angle

Angle of arrow head. Default is 20.

length

A unit specifying the length of the arrow head (from tip to base). Default 0.5.

Examples


library(ggplot2)

# Create a dataset -- mtcars with rownames as column
mt <- mtcars
mt$car <- rownames(mt)

# Make a basic chart with the mtcars data
p <- ggplot(mt, aes(x = mpg, y = wt, label = car)) +
 geom_point() +
 theme_grattan()

# Add a simple callout arrow to the chart, using geom_segment, with arrow = grattan_arrow()
p +
geom_segment(aes(x = 15, y = 2, xend = 19.5, yend = 2.74),
 arrow = grattan_arrow(),
 colour = grattan_red)

# Alternatively we could add a curved arrow, using geom_cuve()
p +
geom_curve(aes(x = 15, y = 2, xend = 19.5, yend = 2.74),
 arrow = grattan_arrow(),
 curvature = 0.3,
 colour = grattan_red)



MattCowgill/grattantheme documentation built on Jan. 13, 2023, 11:02 a.m.