r - Space between gpplot2 horizontal legend elements -


i have ggplot2 plot follows:

library(ggplot2)  ggplot(mtcars, aes(factor(cyl), fill=factor(cyl))) +      geom_bar() +     coord_flip() +     theme(legend.position = 'top') +     guides(fill = guide_legend(title=null)) 

i'd add spacing between fill elements follows:

enter image description here

it seems theme(legend.text = element_text(margin = margin(r = 2, unit = 'in'))) right way accomplish task, doesn't @ all.

instead, (and not first time) fall on microsoft word style of alignment-hacking, i.e. add spaces:

ggplot(mtcars, aes(factor(cyl), fill=factor(paste(cyl, '                    ')))) +      geom_bar() +     coord_flip() +     theme(legend.position = 'top') +     guides(fill = guide_legend(title=null)) 

plot spaced legend

because there's spaces on 8 well, it's little off-center, if paste them onto previous labels can nudge them around like.

apologies nightmares caused graphic designers.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -