New Geometry – Ternary Errorbars
ggtern 1.0.3.1 has introduced a new series of geometries to represent known errors in data, they are relatively easy to use and are along the lines of the geom_errorbar(...)
and geom_errorbarh(...)
geometries in ggplot2.
Analagous the errorbars in ggplot2, in ggtern, the new geometries [and additional required mappings] are thus listed as follows:
- geom_errorbarT(…) [Tmin, Tmax]
- geom_errorbarL(…) [Lmin, Lmax]
- geom_errorbarR(…) [Rmin, Rmax]
These three geometries represent errors relative to the Top, Left and Right apex species, respectively.
Example of Ternary Errorbar Usage
To start with, let us prepare some data:
# Load the data data(Feldspar) IX = c('Ab', 'An', 'Or') #Error bar width width <- 0.01 #Create error data +- 5% for (ix in IX) { Feldspar[, paste0(ix, '_min')] = pmax(Feldspar[, ix] - 0.05, 0) Feldspar[, paste0(ix, '_max')] = pmin(Feldspar[, ix] + 0.05, 1) } #Helper mytitle <- function(x){ ggtitle(paste('Demonstration of: geom_errorbar',x,'(...)',sep="")) } # Set the theme for subsequent plots theme_set(theme_bw())
Top species error bars can be produced with the following:
ggtern(data = Feldspar, aes(x = Ab, y = An, z = Or)) + geom_errorbarT(aes(Tmin = An_min, Tmax = An_max, width = width), color = 'darkred') + geom_point() + mytitle("T")
Left species error bars can be produced in exactly the same manner:
ggtern(data = Feldspar, aes(x = Ab, y = An, z = Or)) + geom_errorbarL(aes(Lmin = Ab_min, Lmax = Ab_max, width = width), color = 'darkblue') + geom_point() + mytitle("L")
Right species error bars, you guessed it, same again:
ggtern(data = Feldspar, aes(x = Ab, y = An, z = Or)) + geom_errorbarR(aes(Rmin = Or_min, Rmax = Or_max, width = width), color = 'darkgreen') + geom_point() + mytitle("R")
Voila!





Related Posts
-
Version 2.2.2 Released
ggtern version 2.2.2 has just been submitted to CRAN, and it includes a number -
Version 2.2.1 Released
It has been a while since any kind of significant update has been released
About Author
Nick Hamilton
Author of the ggtern package. PhD candidate at the University of New South Wales in the School of Materials Science and Engineering. My field is in the simulations of metallic glasses via several advanced simulation techniques such as QMD and RMC.
Leave a Reply
Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Hi Nicholas,
I’ve just updated to ggtern 2.1.1 and an errorbar plot I had before now doesn’t display correctly. I’ve tracked the problem down to the Lmin, Lmax etc. not being normalised before they are plotted. I tried the plots on this page and they also don’t display correctly.
I checked the raw Feldspar data and in commit 44b0f95 it is normalised (rows sum to 1) and in commit a78231e the rows are not normalised. I think one of the best features of the ggtern errorbar was that it did the normalisation of the error bars and I hope it can be restored.
Andy, thanks, I’ll fix this for the next version.