tropf
ABSTRACT
My personal recipes when using R.
I use R mainly for plotting and some data post-processing. This document collects some tricks I encountered and use.
For plotting I use ggplot2, which ist assumed to exist in these examples. A variable p is typically a ggplot2 plot object.
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.
p <- p + guides(fill=guide_legend(override.aes=list(fill=NA))) + theme(legend.text=element_text(color="#00000000"), legend.title=element_text(color="#00000000"))
21 June
2023
Home