title: R ggplot2 control the legend columns
body: <p>I would like to use the <code>ggplot</code> command <code>guides(fill = guide_legend(ncol=3))</code> to show my discrete categories in three columns in my legend.</p>
  <p>But ideally, I would like to</p>
  <p>a) <strong>Organise the legend key columns</strong> in a meaningful way (below that would be all negative categories left, 0 alone in the middle and all positive values in the right column)</p>
  <p>b) Ideally also have a <strong>column heading</strong> for each column (e.g. &quot;positive&quot;, &quot;nothing&quot;, &quot;negative&quot;)</p>
  <p>Currently, as you can see, the columns are simply organised in the order of the factor levels.
  Any ideas how to do this?</p>
  <p>Many thanks for your help!</p>
  <pre><code>library(tidyverse)
  
  map_data(&quot;world&quot;) %&gt;% 
    distinct(region) -&gt; regions
    
  set.seed(1)
  regions %&gt;% 
    mutate(value = sample(-3:3,rep(nrow(regions)),replace=TRUE),
           value = factor(value)) %&gt;% 
    full_join(map_data(&quot;world&quot;),by=&quot;region&quot;) -&gt; world
    
  
  ggplot(world) +
    geom_polygon(aes(x=long,y=lat,group=group,fill=value)) +
    guides(fill=guide_legend(ncol=3)) + 
    coord_quickmap() + 
    theme_void()+ 
    scale_fill_brewer(palette = &quot;RdBu&quot;)+
    theme(legend.position = &quot;bottom&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/4Scwo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Scwo.png" alt="enter image description here" /></a></p>