how to align the legend title to the middle of legend box in ggplot2?
<p>I want to move the legend title <code>sex</code> a little right to the horizontal center of legend box. I tried <code>theme</code> and <code>guide_legend</code> but failed. Both ways won't change the legend title position.</p>

<pre><code># example data from http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/
df1 &lt;- data.frame(
    sex = factor(c("Female","Female","Male","Male")),
    time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")),
    total_bill = c(13.53, 16.81, 16.24, 17.42)
)

library(ggplot2)
p &lt;- ggplot(data=df1, aes(x=time, y=total_bill, group=sex, shape=sex, colour=sex)) +
    geom_line() + geom_point()

# no change
p + theme(legend.title = element_text(hjust = 0.5))
p + guides(color=guide_legend(title.hjust=0.5))
</code></pre>

<p>In addition, I am using ggplot2_2.2.0.</p>