One shared legend for a cowplot grid in R
<p>I just built a grid with package <code>cowplot</code> (to label the plots from A-D). The plots are made with package <code>ggplot2</code>:</p>

<pre><code>pfour&lt;-ggplot(four, aes(x=Concentration, y=Percentage, fill=Phenotype)) + 
 geom_bar(stat='identity',color='black') +
 scale_fill_grey(start = .4, end = .9) + 
 theme_bw()+ylab("Distribution") + 
 xlab("Contentration [mg/ml]") + 
 ggtitle("96 hpf") +
 theme(legend.title = element_text(colour="black", size=10, face="bold")) +
 theme(legend.background = element_rect(fill="white",
                                        size=0.5, linetype="solid", 
                                        colour ="black")) +
 scale_x_discrete(limits=c('uninjected','control','0.002', '0.02', '0.2'),
                  labels=c('uninjected\n(n=251)',
                           'control\n(n=248)', 
                           '0.002\n(n=205)', 
                           '0.02\n(n=222)', 
                           '0.2\n(n=203)'))
</code></pre>

<p>the data looks like that (4 different tables with slightly different percentages but the same principle):</p>

<pre><code>Concentration,Percentage,Phenotype
uninjected,0.996015936,0
uninjected,0,1
uninjected,0.003984064,2
uninjected,0,3
uninjected,0,4
control,0.995967742,0
control,0.004032258,1
control,0,2
control,0,3
control,0,4
0.002,0.985365854,0
0.002,0.004878049,1
0.002,0.004878049,2
0.002,0,3
0.002,0.004878049,4
0.02,0.981981982,0
0.02,0.004504505,1
0.02,0.004504505,2
0.02,0.004504505,3
0.02,0.004504505,4
0.2,0.985221675,0
0.2,0.004926108,1
0.2,0,2
</code></pre>

<p>and it looks like that:</p>

<p><a href="https://i.stack.imgur.com/kL4vQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kL4vQ.png" alt="plot"></a></p>

<p>the code for that is :</p>

<pre><code>plot_grid(ponezoom, ptwozoom,pthreezoom,pfourzoom, align='h', labels=c('A', 'B','C','D'))
</code></pre>

<p>Now I was wondering if it is possible to get <strong>one single shared legend for all four plots</strong> as it steals a lot of plotspace to have it 4 times. I appreciate any help.</p>