plotflow (version 0.2.1)

label_breaks: Break Axis Labels

Description

Break factor level labels onto new lines within plots.

Usage

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.

References

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

Examples

Run this code
# NOT RUN {
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() 
# }

Run the code above in your browser using DataLab