label_breaks: Break Axis Labels

Description Usage Arguments Value Author(s) References Examples

Description

Break factor level labels onto new lines within plots.

Usage

1
label_breaks(dataframe, split.col)

Arguments

dataframe

A dataframe object.

split.col

The column to break its labels onto separate lines.

Value

Returns a data.frame with the factor element spaces replaces with \n.

Author(s)

Mollie Taylor and Tyler Rinker <tyler.rinker@gmail.com>

References

http://www.mollietaylor.com/2013/10/line-breaks-between-words-in-axis.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(1000)
dat <- data.frame(Location = rnorm(1:1000, mean = 200, sd = 75),
    Type = sample(c("Big Red Monster", "Little Green Alien", 
        "One-Eyed, One-Horned Flying Purple People Eater"), 1000, TRUE))

ggplot(dat,  aes(x = Type, y = Location)) + 
    geom_boxplot() 

ggplot(label_breaks(dat, 2),  aes(x = Type, y = Location)) + 
    geom_boxplot() 


ggplot(label_breaks(dat, "Type"),  aes(x = Type, y = Location)) + 
    geom_boxplot() + 
    coord_flip() 

trinker/plotflow documentation built on May 31, 2019, 9:42 p.m.