.TL R Cook Book .AU tropf .AB My personal recipes when using .URL "https://r-project.org/" "R" "." .AE .DA . .NH 1 Intro .PP I use R mainly for plotting and some data post-processing. This document collects some tricks I encountered and use. .PP For plotting I use .URL "https://github.com/tidyverse/ggplot2/" "ggplot2" "," which ist assumed to exist in these examples. A variable .CW "p" is typically a ggplot2 plot object. . .NH 1 Hiding Legend, but Preserving its Space .PP To hide a legend, but still take up its space (e.g. to build plots over multiple instances) add the following to the legend. Adjust the aesthetic used. .CB p <- p + guides(fill=guide_legend(override.aes=list(fill=NA))) + theme(legend.text=element_text(color="#00000000"), legend.title=element_text(color="#00000000")) .CE