gggap_legend: Add Legend to gggap()

Description Usage Arguments Value Examples

View source: R/gggap_legend.R

Description

Add a legend to a 'ggplot2' plot modified by gggap().

Usage

1
2
gggap_legend(plot, margin = c(top = 200, right = 200, bottom = 200, left =
  200))

Arguments

plot

A 'ggplot2' plot.

margin

Margins around the text.

Value

A legend-added picture

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(ggplot2)
mtcars$gear <- factor(mtcars$gear)
bp <- ggplot(
  data = mtcars,
  aes(x = gear, fill = gear)
) +
geom_bar() +
ggtitle("Number of Cars by Gears") +
xlab("Gears")
gggap(
  plot = bp,
  ylim = c(0, 16),
  segments = c(6, 8)
)
gggap_legend(
  plot = bp,
  margin = c(top = 1, right = 1, bottom = 1, left = 460)
)

gggap documentation built on Nov. 20, 2020, 5:08 p.m.