In this section, we'll set our own theme for an individual (or global) plot. Let's begin by implementing the following steps:
- Set up your theme, as follows:
- Change the legend title and position.
- Change the axes titles' colors and relative size (1.5). Using text changes the colors of the axes titles and the legend text, but not the label text.
- Change the axes labels' text sizes; use axis.text: (Note that if you want to change the x and y axes separately, you should use axis.text.x and axis.text.y.)
mytheme <- theme(text = element_text(color="Blue"), axis.text = element_text(size=12),axis.title = element_text(size = rel(1.5)))
- Use your theme with an individual plot:
p2 <- p1+mytheme
(Click on zoom plot if it's not clear or is compressed in the canvas.)
- You can also set it globally for all plots at the beginning of your code:
(theme_set(mytheme)).
The plots with our theme are as follows:
The default colors aren't always the most appealing; you may therefore want to use a different palette, by using the commands scale_colour_brewer (), scale_fill_brewer, or scale_colour_manual() .
Refer to the complete code here: https://goo.gl/RheL2G.