title: multi line and center align x axis labels using ggplot
body: <p>I know <code>hjust</code> is used for the x <strong>title</strong> axis, but how would I go about centering and multilining the x axis <strong>labels</strong>? Here is my plotting function:</p>
  <pre><code>gg_fun&lt;-function(){
    ggplot(tab,                  
           aes(x = Var1, y = Percent)) +
      #theme_light() +
      theme(panel.background = element_rect(fill = NA),
            axis.title.y=element_text(angle=0, vjust=0.5, face=&quot;bold&quot;), 
            axis.title.x=element_blank(),
            axis.text.y = element_text(size = 10), 
            axis.text.x = element_text(size = 12),
            axis.ticks.x = element_blank(),
            axis.ticks.y = element_blank(),
            #panel.grid.minor = element_line(colour = &quot;dark gray&quot;),
            panel.grid.major.x = element_blank() ,
            # explicitly set the horizontal lines (or they will disappear too)
            panel.grid.major.y = element_line(size=.1, color=&quot;dark gray&quot; ),
            axis.line = element_line(size=.1, colour = &quot;black&quot;),
            plot.background = element_rect(colour = &quot;black&quot;,size = 1)) +
      geom_bar(stat = &quot;Identity&quot;, fill=&quot;#5596E6&quot;) + #&quot;cornflower&quot; blue
      ggtitle(element_blank()) + 
      scale_y_continuous(expand =  c(0, 0), breaks = round(seq(0, 1, by = .1), digits = 2), 
                         labels  = percent(round(seq(0, 1, by = .1), digits = 2), digits = 0),
                         limits = c(0,.6)) #+
      #scale_x_discrete()
  }
  </code></pre>
  <p>Here is an example graph it produces:
  <a href="https://i.stack.imgur.com/6SXMN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6SXMN.png" alt="enter image description here" /></a></p>
  <p>I am aware of <code>n.dodge</code> argument for <code>scale_x_discrete()</code>, but this is not what I am looking for. I also do not want to simply abbreviate using <code>labels = abbreviate</code> or specifying precisely as this is time consuming. I have also seen for example <code>levels(birds$effect) &lt;- gsub(&quot; &quot;, &quot;\n&quot;, levels(birds$effect))</code>, but this skips every line and makes some labels far too long. How would I go about centering the x label text as well as having it multiline to prevent overlap? Example of what I am going for:</p>
  <p><a href="https://i.stack.imgur.com/M5CcK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M5CcK.png" alt="enter image description here" /></a></p>