Learn R Programming

ggtern

An extension to ggplot2, for the creation of ternary diagrams.

ggtern is a package that extends the functionality of ggplot2, giving the capability to plot ternary diagrams for (subset of) the ggplot2 proto geometries. Ternary diagrams are used frequently in a number of disciplines to graph compositional features for mixtures of three different elements or compounds. It is possible to represent a coordinate system having three (3) degrees of freedom, in 2D space, since the third dimention is linear and depends only on the other two.

ggtern is a package that is based on (extends) the very popular ggplot2, which is an implementation of Wilkinsons The Grammar of Graphics, and, makes provision for a highly methodical construction process for the development of meaningful (graphical) data representations. Of course, the above book by Wilkinson outlines the theory, whilst Hadley Wickhams ggplot2 implementation is where much of the magic happens, and, an ideal base-platform for ggtern.

Installation

Install the latest release on CRAN, install just like any other R package:

  install.packages('ggtern')

To install the development / working version, use the devtools package:

  devtools::install_git('https://bitbucket.org/nicholasehamilton/ggtern')

Contributing

Please contribute push/pull requests via BitBucket repository. Financial contributions, where possible, are very much appreciated. Please navigate to the ggtern website if you are feeling generous...

Authors

Nicholas Hamilton [aut, cre]

License

This project is licensed under GPL2 - see the LICENSE for details.

Citation

Please cite ggtern via the following:

Hamilton NE and Ferry M (2018). "ggtern: Ternary Diagrams Using ggplot2." Journal of Statistical Software, Code Snippets, 87(3), pp. 1-17. doi: 10.18637/jss.v087.c03 (URL:http://doi.org/10.18637/jss.v087.c03)

A bibtex entry can be obtained by executing the following command:

  citation('ggtern')

Acknowledgments

HUGE thanks to Hadley Wickham and all those that have controbuted to the ggplot2 package, without which, this would not be possible.

Copy Link

Version

Install

install.packages('ggtern')

Monthly Downloads

3,179

Version

3.5.0

License

GPL-2 | file LICENSE

Last Published

March 24th, 2024

Functions in ggtern (3.5.0)

annotation_raster_tern

Annotation: High-performance rectangular tiling (ggtern version)
geom_Xline

Fixed Value Lines
geom_Xisoprop

Fixed Value Isoproportion Lines
.getFunctions

OLD FUNCTIONS new_panel','train_layout','train_position','train_ranges','map_position','map_layout','reset_scales','facet_render', xlabel','ylabel' expand_default', ## REMOVED
approved_layers

Approved Geoms, Stats and Positions
draw_key_tern

Key drawing functions
geom_mean_ellipse

Mean Ellipse
breaks_tern

Generate Axis Breaks
data_USDA

USDA Textural Classification Data
geom_text_viewport

Draw Text at Relative Position on Viewport
data_WhiteCells

Aichisons White Cells
geom_mask

Apply Manual Clipping Mask
geom_tri_tern

Tribin (ggtern version).
geom_label_viewport

Draw Label at Relative Position on Viewport
geom_hex_tern

Hexbin (ggtern version).
geom_crosshair_tern

Ternary Crosshairs
geom_confidence_tern

Confidence Interval
geom_point_swap

Points (Colour and Fill Swapped), as for a scatterplot
ggtern_package

Ternary Diagrams in R
ggtern_labels_arrow_suffix

Atomic, Weight or Custom Percentage Suffix
ggplot_build

Build ggplot for rendering (ggtern version).
ggplot

Create a new ggplot plot.
scale_X_continuous

Ternary Position Scales
strip_unapproved

Strip Unapproved Layers
ggtern_labels

Change Axis labels and legend titles
mahalanobis_distance

Mahalanobis Distance
label_formatter

label_formatter is a function that formats / parses labels for use in the grid.
ggtern

ggtern Constructor
ggsave

Save a ggplot (or other grid object) with sensible defaults (ggtern version)
labels_tern

Generate Axis Labels
zzz-overloaded

Overloaded ggplot2 functions
predictdf2d

Prediction data frame
theme_convenience_functions

Theme Convenience Functions
theme_gridsontop

Render Grids on Top
ggtern_themes

ggtern themes
theme_arrowlength

Change the Length of the Ternary Arrows
ggplot_gtable

Build a plot with all the usual bits and pieces.
geom_polygon_closed

Closed Polygons
geom_interpolate_tern

Ternary Interpolation
theme_complete

List of Available Themes
rgb2hex

Convert RGB to HEX Color
geom_smooth_tern

Add a Smoothed Conditional Mean.
theme_elements

New Theme Elements
theme

Modify components of a theme
theme_nomask

Show or Hide the Clipping Mask
theme_showgrid

Show or Hide Grid
theme_showprimary

Show or Hide the Primary/Secondary Ticks
theme_rotate

Rotate Ternary Diagram
position_jitter_tern

Jitter Ternary Points
kde2d.weighted

Two-Dimentional Kernel Density Estimation (Weighted)
theme_showlabels

Show or Hide Axis Ticklabels
theme_bordersontop

Render Borders on Top
theme_clockwise

Direction of Ternary Rotation
theme_latex

Parse Labels w Latex Markup
position_nudge_tern

Nudge Ternary Points.
tern_limits

Restrict Ternary Limits
transform_position_tern

Convenience function to transform all position variables in a ternary plot
theme_ticklength

Modify the Ticklengths
theme_showtitles

Show or Hide the Axis (Apex) Titles
theme_ticksoutside

Place Ticks Inside or Outside
theme_mesh

Create Grid Mesh
theme_zoom_X

Zoom on Plot Region
ternary_transformation

Ternary / Cartesian Transformation
zzz-internal

Internal Functions
theme_novar_tern

Blank one variable's annotations in ternary plot
zzz-depreciated

Depreciated Functions
theme_noarrows

Show or Hide the Ternary Arrows
theme_legend_position

Position Legend in Convenient Locations
arrangeGrob

Arrange multiple grobs on a page (ggtern version)
annotate

Create an annotation layer (ggtern version).
data_Feldspar

Elkin and Groves Feldspar Data
data_Fragments

Grantham and Valbel Rock Fragment Data
data_SkyeLava

Aichisons Skye Lavas
aes

Modified Aesthetic Mappings
coord_tern

Ternary Coordinate System
geom_density_tern

Density Estimate (ggtern version)
geom_errorbarX

Ternary Error Bars