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:
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))
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
Post a Comment