draw_key_arrowpath: This function replaces 'ggplot2::draw_key_path' and displays...

View source: R/legend-draw-ggarchery.R

draw_key_arrowpathR Documentation

This function replaces ggplot2::draw_key_path and displays all the requested arrowheads.

Description

This function replaces ggplot2::draw_key_path and displays all the requested arrowheads.

Usage

draw_key_arrowpath(data, params, size)

Arguments

data

A single row data frame containing the scaled aesthetics to display in this key

params

A list of additional parameters supplied to the geom.

size

Width and height of key in mm.

Value

A grid grob.

Examples


 library(ggplot2)
 library(magrittr)
 library(tidyr)

 # Generate some dummy data

 ten.points <- data.frame(line.no = rep(1:5, each = 2), x = runif(10), y = runif(10),
                          position = rep(c("start", "end"), 5))
 five.segments <- ten.points %>% pivot_wider(names_from = position, values_from = c(x,y))

 ggplot(five.segments) +
    geom_point(data = ten.points, aes(x = x, y = y)) +
    geom_segment(aes(x = x_start, xend = x_end, y = y_start, yend = y_end), arrow = arrow(),
                 key_glyph = draw_key_arrowpath)


ggarchery documentation built on May 29, 2024, 10:27 a.m.