![]() Title.position = "left", title.vjust = 1))Įxample: for scale_fill_xxx & guide_colorbar ggplot(mtcars, aes(mpg, wt)) + Guides(fill = guide_legend(title = "Cyl", Legend.text = element_text(margin = margin(t = 10))) + ![]() Guides(fill = guide_legend(byrow = TRUE))Įxample: Move the legend key labels to the bottom and increase vertical spacing ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) + Ggplot(mtcars, aes(y = factor(cyl), fill = factor(cyl))) + Note: If you only want to expand the spacing to the right of the legend text, use stringr::str_pad()Įxample: Increase vertical spacing (mind byrow = TRUE) library(ggplot2) Scale_fill_brewer("Cyl", palette = "Dark2") + Ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) + Example below.Įxample: Increase horizontal spacing between legend keys library(ggplot2) Update Dec 2021 - to make work, you will need to set byrow = TRUE in the corresponding guide_legend. Ggplot2 v3.0.0 released in July 2018 has working options to modify, and legend.text.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |