ggclip: ggplot clipping

Description Usage Arguments Examples

View source: R/ggplots.R

Description

Toggles ggplot panel clipping.

Usage

1
ggclip(p, action = 'off')

Arguments

p

a ggplot object

action

turn clipping 'off' (default) or 'on'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(ggplot2)
library(grid)

(q <- qplot(1:10, 1:10,size = I(10)) + scale_y_continuous(expand = c(0, 0)))
ggclip(q)

dat <- data.frame(time = 0:5, y = 0:5)
(p <- ggplot(dat, aes(x = time, y = y)) +
    geom_area(alpha = .1) + theme_bw() +
    scale_y_continuous(expand = c(0, 0)) +
    scale_x_continuous(expand = c(0, 0)) +
    theme(panel.grid.major = element_blank(), 
          panel.grid.minor = element_blank(),
          axis.text.x=element_blank(),
          axis.ticks.x=element_blank()) +
     geom_segment(aes(x = 0, xend = 5 , y = 0, yend = 0), size = 1.5,
                  arrow = arrow(length = unit(0.6, 'cm'))))

ggclip(p)

raredd/plotr documentation built on Nov. 9, 2018, 5:41 p.m.