Available Themes
One of the great features of ggplot2, is the way in which the theme architecture has been implemented. It is very easy to ‘customize’ a plot the way that you like, and, historically, several convenience functions were provided to make it even easier, such as theme_bw()
or theme_gray()
. In this spirit, ggtern has also implemented some theme-based convenience functions, and the purpose of this post is to illustrate the differences.
Firstly, lets create a default plot:
library(ggtern) plot <- ggtern(data = data.frame(x = 1, y = 1, z = 1), aes(x, y, z)) + geom_point()
Continue to the next pages, to see some simple theme variations…
Default Gray
last_plot() + theme_gray()
Black and White
last_plot() + theme_bw()
Red-Green-Blue and White
last_plot() + theme_tern_rgbw()
Red-Green-Blue and Gray
last_plot() + theme_rgbg()
Without Grid (Minor Only Removed)
last_plot() + theme_bw() + theme_nogrid_minor()
Without Grid (Minor AND Major Removed)
last_plot() + theme_bw() + theme_nogrid()
Without Grid and Without Arrows
last_plot() + theme_bw() + theme_nogrid() + theme_noarrows()





Comments
Hej Nick,
I have upgraded to ggtern 2.1.0, but none of the theme functions can be found (R version 3.2.1, Ubuntu 14.04):
R version 3.2.1 (2015-06-18) — “World-Famous Astronaut”
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type ‘license()’ or ‘licence()’ for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type ‘contributors()’ for more information and
‘citation()’ on how to cite R or R packages in publications.
Type ‘demo()’ for some demos, ‘help()’ for on-line help, or
‘help.start()’ for an HTML browser interface to help.
Type ‘q()’ to quit R.
> library(ggtern)
Loading required package: ggplot2
Attaching package: ‘ggtern’
The following objects are masked from ‘package:ggplot2’:
aes, calc_element, ggplot, ggplot_build, ggplotGrob, ggplot_gtable,
ggsave, is.ggplot, layer_data, layer_grob, layer_scales, theme,
theme_bw, theme_classic, theme_dark, theme_get, theme_gray,
theme_light, theme_linedraw, theme_minimal, theme_set, theme_void
> plot last_plot() + theme_tern_gray()
Error: could not find function “theme_tern_gray”
> last_plot() + theme_tern_bw()
Error: could not find function “theme_tern_bw”
> last_plot() + theme_tern_rgbw()
Error: could not find function “theme_tern_rgbw”
> last_plot() + theme_tern_rgbg()
Error: could not find function “theme_tern_rgbg”
> last_plot() + theme_tern_bw() + theme_tern_nogrid_minor()
Error: could not find function “theme_tern_bw”
> last_plot() + theme_tern_bw() + theme_tern_nogrid()
Error: could not find function “theme_tern_bw”
> last_plot() + theme_tern_bw() + theme_tern_nogrid() + theme_noarrows()
Error: could not find function “theme_tern_bw”
>
Sorry most of these syntaxes are left over (now defunct) from the first version of ggtern, and I havn’t updated the webpage. Ill update this page soon.
Love it! I ran the code shown in the faceting example:
http://www.ggtern.com/faceting/
but the filled contours are missing from my plot. Any ideas?
Mike
Hi,
theme_bw() kills the arrows.
MWE
ggtern(data = data.frame(x = 1, y = 1, z = 1), aes(x, y, z)) + geom_point() + theme_showarrows()
# this HAS arrows
last_plot() + theme_bw()
# This does not