title: How to align the legend box to the middle of legend title in ggplot2?
body: <p>By default the legend box/key is aligned to the left of the legend title. Since I have quite long legend title, I want to align it to the center instead. I have tried <code>theme</code> and <code>guide_legend</code> without any success. Any suggestion would be appreciated. Thanks!</p>
  
  <ul>
  <li><p>Data</p>
  
  <pre><code>df &lt;- structure(list(Flow = c(0.992762, 0.802408, 0.9826, 0.754863, 
          0.174542, 0.056777), Coef = c(0.62, 0.49, 0.38, 0.59, 0.25, 0.67
          ), VeryLongLegendTitle = c(4.47680710313542, 18.8500193246859, 
          5.82742564783431, 23.3217237977105, 13.0155332302148, 88.4960885143824
          )), class = "data.frame", row.names = c(NA, -6L), .Names = c("Flow", 
          "Coef", "VeryLongLegendTitle"))
  </code></pre></li>
  <li><p>Code</p>
  
  <pre><code>library(ggplot2)
  p1 &lt;- ggplot(df, aes(x = Flow, y = Coef, color = VeryLongLegendTitle)) +
    xlab(NULL) + scale_x_continuous(limits = c(0.0, 1.0), breaks = c(0.25, 0.75)) +
    geom_point(size = 2, alpha = 0.8) + 
    theme_bw(base_size = 14) +
    theme(axis.text.x = element_text(angle = 0, vjust = 0.5))
  p1
  
  p1 + theme(legend.title.align = 0.5) 
  p1 + theme(legend.title = element_text(hjust = 0.5))
  p1 + guides(color = guide_legend(title.hjust = 0.5))
  </code></pre></li>
  <li><p>Plot
  <a href="https://i.stack.imgur.com/3xjJs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3xjJs.png" alt="enter image description here"></a></p></li>
  </ul>