I have a global variable with the theme for ggplot2:
cPlotOpts <- opts (axis.text.x = theme_text (size=10, colour="grey50"), axis.text.y = theme_text (…
and I would like to add one argument to it later in the code but without modifying those already set, so that
axis.text.x = theme_text (size=10, colour="grey50", angle=90)
How can I add this one argument (angle) to the already defined theme_text without having to explicitly repeat the settings for size and colour?
[Edited after the first answer for greater clarity.]
I think the easiest approach is to just use a function.
cPlotOpts <- function(size = 10, colour = "grey50", ...) {
opts(axis.text.x = theme_text (size=size, colour=colour, ...))
}
then to add an argument later, simply:
cPlotOpts(angle=90)
which yields:
cPlotOpts(angle=90)
$axis.text.x
theme_text(colour = colour, size = size, angle = 90)
attr(,"class")
[1] "options"
If you do not want it edited, just use cPlotOpts(). Is something like that acceptable?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With