Note that there are some explanatory texts on larger screens.

plurals
  1. POReducing legend size in ggplot beyond default size
    text
    copied!<p>My goal is to make several plots with <code>ggplot</code> and combine them into a single plot using <code>grid.arrange</code> in the <code>gridExtra</code> package.</p> <p>I'm having an issue in that the legends in my <code>ggplot</code> (while appropriately sized for a single plot) are too large when I try to place the plots side by side with <code>grid.arrange</code>. The resulting combined plots reduce the x-axis but keep the legend original size. So the result is a very skinny plot, next to an needlessly large legend. So I'd like to reduce the size of the legend in each plot, enough so that I can place my plots side by side. Or possible shrink them enough to bring them inside the actual plot without being to overbearing.</p> <pre><code>V1&lt;-rnorm(10) V2&lt;-rnorm(10) V3&lt;-rnorm(10) DF&lt;-data.frame(V1,V2,V3) ggplot(DF,aes(x=V1,y=V2,size=V3))+ geom_point(fill='red',shape=21)+ theme_bw()+ scale_size(range=c(5,20)) </code></pre> <p>This plot command produces a standard legend size to the right of the plot.</p> <p><img src="https://i.stack.imgur.com/HKK2M.jpg" alt="enter image description here"></p> <p>I've tried using different theme elements:</p> <pre><code>+theme(legend.key.size = unit(0.5, "cm") </code></pre> <p>or</p> <pre><code>+theme(legend.key.width=unit(0.3,"cm"),legend.key.height=unit(0.3,"cm"),legend.position = c(0.7, 0.8)) </code></pre> <p>And while I can make the legend larger using these theme commands, I can't make the legend any smaller than the default legend. So is there any way to shrink the legend beyond the default size?</p> <p>I can also change the default size of my pdf device to make it wider and accommodate the large legends , but I'd like to work with a standard pdf size for now. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload