title: r - How can I get a lengthy label to fit using facet_grid in ggplot2?
body: <p>Here is a reproducible example:</p>
  
  <p>I first create a function based on this example <a href="https://github.com/hadley/ggplot2/wiki/labeller" rel="nofollow noreferrer">https://github.com/hadley/ggplot2/wiki/labeller</a> then provide the data and a graph</p>
  
  <pre><code>label_wrap_gen &lt;- function(width = 100) {
    function(variable, value) {
      lapply(strwrap(as.character(value), width=width, simplify=FALSE), 
             paste, collapse="\n")
    }
  }
  
  Data &lt;- data.frame(Language=c("C++","C++","C++", "Java","Java","Java","Java", "PythonhasaREALLYWAYTOOlonglabel"), 
                  Files=c(400, 210, 35,55,330,220,213,76), 
                  Difficulty=c("a","b","c","d","e","f","g","h"), 
                  stringsAsFactors=FALSE)
  
  g &lt;- ggplot(Data,aes(x=Difficulty,y=Files,fill=Difficulty))  #replaced fill=feetype,
  h &lt;- g + geom_bar(stat="identity",position="dodge") +   facet_grid(.~ Language, scales = "free_x", space="free",labeller=label_wrap_gen(width=.1)) 
  h
  </code></pre>
  
  <p>which produces a ggplot graph with a label for "PythonhasaREALLYWAYTOOlonglabel" that will oftentimes run off the edge of the plot.  </p>
  
  <p>I've tried playing with the various <code>geom_bar</code> widths from the following link but too no avail:
  <a href="https://stackoverflow.com/questions/12040245/how-to-increase-the-space-between-the-bars-in-a-bar-plot-in-ggplot2">How to increase the space between the bars in a bar plot in ggplot2?</a></p>
  
  <p>Any help here?
  Thanks so much.</p>