title: ggplot2: Divide Legend into Two Columns, Each with Its Own Title
body: <p>I have these factors</p>
  <pre><code>require(ggplot2)
  names(table(diamonds$cut))
  # [1] &quot;Fair&quot;      &quot;Good&quot;      &quot;Very Good&quot; &quot;Premium&quot;   &quot;Ideal&quot; 
  </code></pre>
  <p>which I want to visually divide into two groups in the legend (indicating also the group name):</p>
  <pre><code>&quot;First group&quot; -&gt; &quot;Fair&quot;, &quot;Good&quot;
  </code></pre>
  <p>and</p>
  <pre><code>&quot;Second group&quot; -&gt; &quot;Very Good&quot;, &quot;Premium&quot;, &quot;Ideal&quot;
  </code></pre>
  <p>Starting with this plot</p>
  <pre><code>ggplot(diamonds, aes(color, fill=cut)) + geom_bar() + 
    guides(fill=guide_legend(ncol=2)) +
    theme(legend.position=&quot;bottom&quot;)
  </code></pre>
  <p>I want to get</p>
  <p><img src="https://i.stack.imgur.com/ce7uR.png" alt="enter image description here" /></p>
  <p>(note that &quot;Very Good&quot; slipped in the second column/group)</p>