Wrapping a custom theme function
After using ggplot2
and performing theme changes several times, there are always theme tweaks you find yourself going for too often. This recipe goal is to demonstrate how to wrap theme functions into tailormade ones. Wrapping your preferences in a single function makes the process of crafting publish quality plots so much easier.
Getting ready
This recipe will test the custom theme function in the bubble
object created by previous recipe, Drawing a bubble plot. If you wish to keep this way, make sure to have this object on your environment by running the recipe if it's missing. Another option is to draw an gg
object of your own to replace bubble
into the recipe. Do as you please.
How to do it...
Let us start with wrapping a custom theme function:
- Create a function that calls for
theme()
:
> theme_custom <- function(s.legend1 = 14, s.legend2 = 14, s.axes1 = 14, s.axes2 = 15, ....