Align title of a legend in ggplot
<p>I am trying to change the alignment of a legend title in ggplot. Specifically, I would like to put the title of a horizontal legend above the legend keys instead of on the left (default). It seems like I should be able to use <code>theme(legend.title.align)</code>, however that function does not seem to have any effect. I even tried using it for the default vertically-aligned right legend with no success.</p>

<p>Example below using <code>mtcars</code></p>

<pre><code># Horizontal legend placed below plot
ggplot(mtcars, aes(x = hp, y = mpg, color = factor(cyl))) +
 geom_point() +
 theme(legend.position = 'bottom',
       legend.direction = 'horizontal')

# Vertical legend right of plot with attempt at right alignment
ggplot(mtcars, aes(x = hp, y = mpg, color = factor(cyl))) +
  geom_point() +
  theme(legend.position = 'right',
  legend.direction = 'vertical', 
  legend.title.align = '1')
</code></pre>

<p>Is there a way to change the position of the legend.title in ggplot, particularly for placing the title above a horizontal legend?</p>